Caching on still images

I have a php site using html5 to run on linux server on godaddy. I need to set cache expiration date on static images and css file. I also need a gzip css file and cannot find the correct syntax. I'm not sure if I am doing this too complicated or what. Do I think I can do this with the expire header at the top of my php pages? I feel lost and I know what I'm doing! I do not control the server.

+8
php caching
Jan 19 '10 at 22:31
source share
5 answers

This is definitely possible if you have control over the server and possibly through .htaccess if you use shared hosting.

Try these questions:

  • How to gzip my files
  • How to set cache expiration date for entire jpg folder using .htaccess
  • Why is this not javascript and css caching? (with full examples)
+3
Jan 19 '10 at 22:37
source share

Godaddy can be very frustrating. I have been looking for a way to use the expires header with the Godaddy move for some time and have not yet found a solution.

I have the following in htaccess ("A2592000" means 1 month) and it works with other hosts, but not with Godaddy :(

ExpiresActive On ExpiresDefault A0 ExpiresByType image/gif A2592000 ExpiresByType image/png A2592000 ExpiresByType image/jpg A2592000 ExpiresByType image/jpeg A2592000 ExpiresByType image/ico A2592000 ExpiresByType text/css A2592000 ExpiresByType text/javascript A2592000 
+2
Jul 02 2018-10-10T00:
source share

I had the same problem. Disaster with GoDaddy. Never again their hosting :(

But I found a solution: https://support.godaddy.com/help/article/6908/enabling-mod_expires-with-your-hosting-account?locale=en

I do not know how you manage your hosting, but I use FileZila to connect to FTP. Therefore, after connecting to FTP, you can overwrite the .htaccess :) file, so download the original and add this code after:

 <IfModule mod_expires.c> # Activate mod_expires for this directory ExpiresActive on # locally cache common image types for 7 days ExpiresByType image/jpg "access plus 7 days" ExpiresByType image/jpeg "access plus 7 days" ExpiresByType image/gif "access plus 7 days" ExpiresByType image/png "access plus 7 days" # cache CSS files for 24 hours ExpiresByType text/css "access plus 24 hours" 

Hope this helps you. (it helped me: D)

+1
May 05 '15 at 9:26
source share

You can try this

 <FilesMatch "\.(jpg|png|gif)$"> ExpiresDefault A0 Header set Cache-Control "max-age=0, no-cache, must-revalidate" </FilesMatch> 

This means that the expiration date is at the time of access and sets the headers to 0 values.

As you can see, here you can add more file types.

/ via http://blog.simplemediacode.com/cache-expiration-on-static-images-and-content-with-htaccess/

0
Feb 10 '10 at 8:40
source share

You are looking for something like this:

 Header set Cache-Control "max-age=2678400" 

Where the maximum age is set in seconds.

Additionally, if your content is still not cached, read my post in Why not caching javascript and css? for extra caching-config-magic.

0
Dec 13 '11 at 10:50
source share



All Articles