Jump to content

Cacheing


echofool

Recommended Posts

Okay i keep trying to improve my sites speed and work load so want to cache images... i get this (see image link) but no idea how i apply it to images.Image: http://i52.tinypic.com/14imtj4.pngI was told to edit my HTTP headers, yet no one tells me how you do that lol Is it a file some where in my server or what :S So many articles on what it is and what settings are good but not how to edit them.Any one able to explain?

Link to comment
Share on other sites

Okay i keep trying to improve my sites speed and work load so want to cache images... i get this (see image link) but no idea how i apply it to images.Image: http://i52.tinypic.com/14imtj4.pngI was told to edit my HTTP headers, yet no one tells me how you do that lol Is it a file some where in my server or what :S So many articles on what it is and what settings are good but not how to edit them.Any one able to explain?
Theres several different mechanisms for client side caching. If you're using an apache server you can turn ETags for files on: http://httpd.apache.org/docs/2.0/mod/core.html#fileetagAdd
FileETag All

to an ".htaccess" file in your root directory.Otherwise there is also the apache "Expires" module: http://httpd.apache.org/docs/2.0/mod/mod_expires.html e.g.

ExpiresActive OnExpiresByType image/gif "access plus 5 hours"

I can only give advice for apache because I'm not familiar with other HTTP server software.

Link to comment
Share on other sites

yes apache is what i use, am i able to set it on js too ?And what is recommended hours usually?my htaccess currently has:Options -IndexesFileETag AllIs there much else i can add?
Well, like I said, if you have access to the Expires module you can use that along with ETags. Personally, I think ETags are sufficient, although if you use the expires module, when the browser considers requesting a cached image, it doesn't even have to send a request because it sees the timer hasn't expired yet. So using the Expires module would be easier on the server than just using ETags alone. That is all my understanding at least. With ETags alone, the browser has to send the request headers so the server can compare the If-None-Match header to the file's current ETag in order to decide whether to respond with the file.The expire time you set should be based on how frequently you think the images on your server might be updated. If it is important for someone to see one of your images as soon as they're updated, just use ETags. If you think it is important, but not extremely important, maybe use Expires with "access plus 30 minutes". If it's less important use, "access plus 2 hours", and so on.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...