-
-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache-Control: immutable
#148
Comments
Thanks for your suggestion, @Malvoz!
Generally I'm in favor to follow new standards, but here I'm concerned by the potential downsides of the
|
Yes good catch, it could be commented out with notes on TLS/SSL. The web is moving towards an "HTTPS first" web and there are other HTTP header fields that indeed require HTTPS. I would be surprised if H5BP does not move to an HTTPS-first approach in the future with HTTP configurations commented out instead.
Are there equivalent approaches of |
No, but Expires header is added by Apache automatically for backward compatibility only. |
Here's also a nice read about Expires header vs Cache-Control and why Expires header is deprecated... |
Just to be clear here: |
I guess I was confused by "Expires" and the "ExpiresActive" setting... |
The only benefit I see using
So unless I'm aware of that fact (I realize there is a note on this), this is already an issue with: server-configs-apache/dist/.htaccess Line 1047 in 9481d53
server-configs-apache/dist/.htaccess Lines 1077 to 1079 in 9481d53
|
Self quote:
Maybe you could do something like: |
Now that this issue is about
server-configs-apache/src/web_performance/filename-based_cache_busting.conf Lines 9 to 11 in 5dc823c
In 2008 Steve Souders wrote about Squid not caching resources with query string parameters. But it's been around 10 years since Squid changed that behavior:
|
Friendly bump :) The
And it's backwards compatible, browsers that don't understand it just ignores it and uses Perhaps we can set an environment variable at:
and respond to request within that environment with:
Now, I'm not comfortable with apache env variables so if you agree with this, you can PR or help me set it up :) |
OK, we can start thinking of an implementation. Webhint suggests the following: # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Where needed add `immutable` value to the `Cache-Control` header
<IfModule mod_headers.c>
# Because `mod_headers` cannot match based on the content-type,
# the following workaround needs to be done.
# 1) Add the `immutable` value to the `Cache-Control` header
# to all resources.
Header merge Cache-Control immutable
# 2) Remove the value for all resources that shouldn't be have it.
<FilesMatch "\.(appcache|cur|geojson|ico|json(ld)?|x?html?|topojson|xml)$">
Header edit Cache-Control immutable ""
</FilesMatch>
</IfModule> As we already did with other conditional headers, we may use MIME type expressions instead. (and as you suggested)
I don't feel confortable adding environment variables. Hard to understand when they are evaluated, hard to debug.
This is a different issue, but you are right. |
As an aside, I've already opened an issue at webhint about Apaches ability to match based on content-type. The example also seems to have syntax errors, and they should use a long In the following example, I'm matching against every file that is not
This would match e.g. To meet your want/requirement of having file-name based matching, can we then just apply some regex for |
I'm yet to find any up-to-date sources to verify proxies/CDNs having issues with query strings in the modern web (again, Squid introduced caching of query strings as a default in 2008~). But perhaps I haven't searched hard enough. ^^ |
Let's start with MIME-type only first. We'll see cache busting later. And I think we should prefer merging over setting Cache-Control header to add the
Lack of feature or correctness is never documented. 😆 |
I overlooked that in the example. However I don't think
Although I don't know why a developer would, but in any case a developer uses |
Revisiting this; reusing the same MIME-types as used in <IfModule mod_headers.c>
Header set Cache-Control "max-age=31536000, immutable" "expr=%{REQUEST_URI} =~ m#^(.+)\.(\w+)\.(bmp|css|cur|gif|ico|jpe?g|m?js|a?png|svgz?|webp)$#i"
</IfModule> /cc @LeoColomb |
A self-reminder to look into this more, while the example above would make sure that other directives (such as Q: do transcoding intermediaries (proxies and others) only require Not sure if answer lies somewhere in https://support.google.com/webmasters/answer/6211428?hl=en says (emphasize mine):
Edit: I guess this could be solved by proper ordering in .htaccess, setting the Header |
In a way to get things working yes, but the perfect order is mostly impossible. |
The
cache-control
header (which takes precedence overexpires
if present) has been asked about before in #85 and #73.I would like to raise this again because the header provides finer control than
expires
. Also with the addition of theimmutable
directive (see blog posts 1, 2, 3), we get a performance benefit but also no longer have to set longmax-age
directives for infinite caching.The text was updated successfully, but these errors were encountered: