|
I have a website which gets updated sporadically, but most of the time when I go online to check the updates, it shows me a old cached version. I have been trying forever to figure out how to control caching successfully without luck until today. I finally found articles on how to control caching via the .htaccess file in my server directory. I want all of my background images and such to cache for three months and all of my text and such to cache for one week. But I also want it to check to make sure that there haven't been any modifications even before those time periods are up, and to update the page as necessary if there have been.
After wading my way through many pages on the topic, I have patched together some possible code and I would like any feedback on whether this code will do what I described above.
# cache images for 3 month
<FilesMatch ".(gif|jpg|jpeg|png|flv|swf|ico)$">
Header set Cache-Control "max-age=7257600, must-revalidate"
</FilesMatch>
# cache everything else for 1 week
<FilesMatch ".(js|css|pdf|txt|html|htm)$">
Header set Cache-Control "max-age=604800, must-revalidate"
</FilesMatch>
# disable caching for dynamic files
<FilesMatch ".(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
Thank you for any feedback, Layla
|