Leveraging Browser Caching: Expires vs Cache Control?
-
Hi everyone. Finally, after two years of page speed tests telling me to leverage browser caching, I understand what it means and I’m comfortable enough to give it a try. I need a little help, though.
Right now I’m using the “expires” method, and this is the code I have in place in .htacces:
## LEVERAGE BROWSER CACHING ## <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType application/pdf "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" ExpiresByType application/x-shockwave-flash "access plus 1 month" ExpiresByType image/x-icon "access plus 1 year" ExpiresByType application/x-font-woff "access plus 1 weeks" ExpiresDefault "access plus 2 days" </IfModule> ## LEVERAGE BROWSER CACHING ##
My first question is, do I need the word “plus” or not? In the examples I’ve come across, I’ve see it with and without the “plus.” Which is correct?
Also, I’m reading that using the cache-control method might be better. Would this be correct:
# 1 Month for most static assets <filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$"> Header set Cache-Control "max-age=2592000, public" </filesMatch>
If I use cache-control, should I delete the “expires” code?
Another question: How do I ensure that pages are updated in browsers after making changes to style.css, for example?
My website is https://psychopathsandlove.com/invalidation/
Thank you very much for your help!
- The topic ‘Leveraging Browser Caching: Expires vs Cache Control?’ is closed to new replies.