I currently use this setup in my vhost:
<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</Location>
<Directory />
ExpiresActive On
ExpiresByType text/html "access plus 5 minutes"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresDefault "access plus 1 day"
<FilesMatch "\.(ico|jpeg|pdf|flv|jpg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
Header unset Last-Modified
Header unset ETag
FileETag None
</FilesMatch>
<FilesMatch "\.(html|php)$">
Header set Cache-Control "max-age=900, public, must-revalidate"
</FilesMatch>
</Directory>
While it works great for speeding up the thing, sometimes users dont see the changes they themselfs made on content (mainly while using FireFox) :( any suggestions / optimization hints?
Instead of forcing the browser to cache, you should send a must-revalidate header and control the caching from within your programming language (for example, PHP) by sending an Expires and Last-Modified header. The browser will then ask your site for the latest version on each request, but make sure to answer with an empty page if nothing has changed.
This may take some time to implement, but it definitely works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With