I’ve setup a browser cache for a static site via the .htaccess
file by setting:
# BROWER CACHING - 1 Day for images
<filesMatch ".(jpg|jpeg|gif|ico)$">
Header set Cache-Control "max-age=86400, public"
</filesMatch>
I’m fine with these images having a 1 day cache, but the site changes frequently and thus I don’t want to cache the CSS and JS files.
I’ve read about ETag, which, as I understand, allows you to cache a file, but also set its creation date, so if it gets updated the next time a client visits the site, it will check if the creation date matches.
You would use either FileETag MTime Size
or Header unset Etag
and FileEtag none
. Do not use both (Create ETag and Remove ETag) and only choose which one works best on your particular server.
# Create the ETag (entity tag) response header field
FileETag MTime Size
or
# Remove the ETag (entity tag) response header field
Header unset ETag
FileETag none