Closed creopard closed 5 months ago
Thanks for opening this issue @creopard.
That being said, the behavior you are facing is weird.
Indeed, the unit test framework used to validate the configuration explicitly checks Cache-Control
value:
I'm not excluding the option that these tests are weak, but I'd appreciate more investigation on your side.
Are you sure LiteSpeed is following ExpiresDefault
same as Nginx?
Are you sure LiteSpeed is following
ExpiresDefault
same as Nginx? I've looked up the default config, although I can't access the one used by the webhoster. It seems the default comes from the main/global config file: https://openlitespeed.org/kb/openlitespeed-directive-working-in-progress/#expiresDefaultexpiresDefault A604800 expiresByType image/*=A604800, text/css=A604800, and so on...
meaning that everything defaults to 1 week. I was also wondering where that 1 week setting initially came from.
Assumption: If the value of expiresDefault
will be overridden by the .htaccess with access plus 1 year
, this seeting does not seem to affect the preset done in the above main config file expiresByType image/*=A604800
but only types that have no default setting yet.
Hence, (in my case) I need to explicitly set expiresByType image/*
as well in the .htaccess file order to override the default from the main file.
It would be great if anybody else could also look up the expiry dates of images in a real world example. Or is it just me? In the latter case, we can close this issue of course ;-)
Assumption: If the value of
expiresDefault
will be overridden by the .htaccess withaccess plus 1 year
, this seeting does not seem to affect the preset done in the above main config fileexpiresByType image/*=A604800
but only types that have no default setting yet.
That sounds to be the good assumption 😊 But it is for the same assumption that I'd advocate to avoid uncommenting this section. It's always easier to raise the granularity when needed than "fixing" the upper specific generics. I hope it makes sense!
Sure, I would just make people (who can't see the webhosters config, if they are on shared environments) aware that the entry
ExpiresDefault "access plus 1 year"
does not seem to be an automatic fallback scenario for every type that have not been mentioned in the .htaccess explicitly.
@creopard Sounds reasonable. Would you like to submit a PR to add this note?
Added pull request: https://github.com/h5bp/server-configs-apache/pull/371
Thanks!
Expected result:
Image files like PNG, GIF, JPG, WEBP, etc. use the default fallback time thats defined with "ExpiresDefault", i.e. 1 year.
Actual result:
Google Lighthouse complaines about "Serve static assets with an efficient cache policy" as the images will only have a cache TTL of 7 days (=604800 seconds).
Tested Browsers: Chrome 123, Firefox 124 Webserver: I do not run an Apache webserver, but a "Litespeed" webserver (Apache compatible alternative).
Issue:
With the current setting of https://github.com/h5bp/server-configs-apache/blob/1dc1bbdbba468a61d556a0711ba16653a81ba974/dist/.htaccess#L1096
The HTTP answer header of an image will look like this:
Fix:
Uncommenting https://github.com/h5bp/server-configs-apache/blob/1dc1bbdbba468a61d556a0711ba16653a81ba974/dist/.htaccess#L1139 will set the cache TTL correctly to 1 year (= 31536000 seconds).
So it seems that the currently commented section of "Generic:" does not use the fallback time of "ExpiresDefault" as initially anticipated?