mattyvx Posted February 5, 2011 Share Posted February 5, 2011 Right, i've reached cache control on my TO-DO list of website improvements... I've read numerous articles and samples but I can get my head round what parameters I should be using. I've got to this stage; Header unset Pragma FileETag None Header unset ETag # 1 YEAR <FilesMatch "\.(ico|pdf|flv)$"> Header set Cache-Control "max-age=29030400, public" </FilesMatch> # 1 WEEK <FilesMatch "\.(jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch> # 2 DAYS <FilesMatch "\.(xml|txt|css|js)$"> Header set Cache-Control "max-age=172800, must-revalidate" </FilesMatch> # 1 Hour <FilesMatch "\.(html|htm|php)$"> Header set Cache-Control "max-age=3600, must-revalidate" </FilesMatch> # 2 DAYS <FilesMatch "main.php"> Header set Cache-Control "maxage=172800, must-revalidate" </FilesMatch> The main.php file compresses my CSS file so I have set a specfic cache of 2days for that so it doesn't fall under normal php caching of 1 hour. A few questions, I don't understand why i'm using public/private and must re-validate; When should I use public or private? When should I use must re-validate and what are other options/applications for this parameter? Anything i'm missing here? Quote Link to comment https://forums.phpfreaks.com/topic/226826-cache-control-htaccess/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.