Jump to content

Cache control .htaccess


mattyvx

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/226826-cache-control-htaccess/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.