- if there is no expires http header set in the response , what does it mean for browsers?
- In Glassfish v3, how to configure expires header for static resources that have been deployed under docroot not as a war file?
- I noticed that Glassfish seems to set ETag header by default. Is that true?
The ultimate goal I want to achieve here is to set a far future expires header but be able to tell browsers “there is new stuff” whenever new version of css, js, image files are deployed.
Thanks so much for any advices.
For
expiresnot provided in header of the server response, see §14.21 here:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Even when provided,
expiresis overriden by themax-agedirective, thus ifexpiresis not providedmax-ageis used. If none are provided, then see §13.2.4 here:http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2.4
Basically it says the client can set cache for an undetermined period of time, and not consistently.
To solve your problem, you may say your static elements never expire, and add an expire time to the included elements of a HTML doc. To do that, see here:
http://www.tipsandtricks-hq.com/how-to-add-far-future-expires-headers-to-your-wordpress-site-1533
Quoted: “To add expires header to the image, CSS, javascript files add the following to your
.htaccessfileExpire Header
or Expire images header
[…]
Keep in mind that when you use expires header the files are cached in the browser until it expires so do not use this on files that changes frequently. If you change/update a file that has a far future expiry (eg. CSS or javascript files) then you should rename that file and use the renamed version so the browser doesn’t fetch the old file.”