Expires Headers

jensen

Active Member
Messages
1,168
Reaction score
22
Points
38
Been looking at optimizing websites and am trying to understand where to put this "Expire Headers" - http://www.web-caching.com/mnot_tutorial/how.html

From what I understand HTTP is done at server side not like HTML where one can code into a page.

So can I do anything to follow the suggestion to set my images to refresh say like in a week's time? Or there's nothing that can be done?
 

AngusThermopyle

Active Member
Messages
319
Reaction score
52
Points
28
In the .htaccess file that contains your images add something like:

Code:
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600
  
 #  Exceptions ...

 # since .php files tend to be dynamic, do not add expirations
  <FilesMatch \.php$>
    ExpiresActive Off
  </FilesMatch>

 # specific extensions, most image types... 30 days
  <FilesMatch \.(jpg|png|gif|jpeg)$>
 
    ExpiresDefault A2592000
  </FilesMatch>
</IfModule>
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
(The values are in seconds, in case that wasn't clear.)
 

jensen

Active Member
Messages
1,168
Reaction score
22
Points
38
Thanks. now to work with .htaccess and maybe get my page up to speed.
 
Top