Jump to content

image expire date


bluetoother

Recommended Posts

how can i setup a date for images in my web site to expire after a period of time from the browser cache ,, so the browser have to download the image in the next visit to the sitein the same time i want some images to stay in the client's browser cache so they don't have to download it every week for examble because that images never change in my web siteso users will get faster navigation in my web site

Link to comment
Share on other sites

I can't help you, but try posting this in the Javascript part of the forum.

Link to comment
Share on other sites

an .htaccess entry should work

### activate mod_expiresExpiresActive On### Expire .gif's 1 month from when they're accessedExpiresByType image/gif A2592000### Expire .jpg's 1 month from when they're accessedExpiresByType image/jpg A2592000### Expire .jpeg's 1 month from when they're accessedExpiresByType image/jpeg A2592000### Expire .png's 1 month from when they're accessedExpiresByType image/png A2592000

The 'A' means from Last Accessed time, and the numeric portion is Unix time in seconds (60 x 60 x 24 x 30) for 1 month.A week would be (60 x 60 x 24 x 7) = 604000A day is (60 x 60 x 24) = 86400

Link to comment
Share on other sites

Yes, Meta tags will set an expiry date, too, but I believe the date for meta-tags is a specific date, not "30 days in the future", and for the entire page. I don't know if you can assign the expiry date for the Images on the page, though. I might be wrong. Also, having re-read the Opening Post to this topic, you seem to be asking for some images to expire immediately and some at a future date based on the last access date. Can't have both as far as I know. One or the other.*UNLESS*You use the .htaccess method above and serve jpegs for the short expiry images and jpg for the future expiry ones with different values for each type??? Or something like that.

### Expire .jpg's 1 month from when they're accessedExpiresByType image/jpg A2592000### Expire .jpeg's 1 week from when they're accessedExpiresByType image/jpeg A846400### Expire .png's as soon as they're accessedExpiresByType image/png A0

See what I mean? That should work.

Link to comment
Share on other sites

how can i setup a date for images in my web site to expire after a period of time from the browser cache ,, so the browser have to download the image in the next visit to the sitein the same time i want some images to stay in the client's browser cache so they don't have to download it every week for examble because that images never change in my web siteso users will get faster navigation in my web site
I was interested in this question and did a bit of googling.I found more than one reference to being able to do exactly this, by setting an Expires Header for an individual image.For instance, here.Trouble is, I could not find any answer about how or where to set an Expires Header....
Link to comment
Share on other sites

Got a bit closer at http://www.web-caching.com/mnot_tutorial/how.html:

Most Web servers allow you to set Expires response headers in a number of ways. Commonly, they will allow setting an absolute time to expire, a time based on the last time that the client saw the object (last access time), or a time based on the last time the document changed on your server (last modification time).Expires headers are especially good for making static images (like navigation bars and buttons) cacheable. Because they don't change much, you can set extremely long expiry time on them, making your site appear much more responsive to your users.
So it's set on the webserver, and can be applied to individual images. I'll have a dig when I can about how to do this in IIS.
Link to comment
Share on other sites

if the server is set up properly, they will send a head consist of eTag for every resources, html, php, images are no exceptions. The eTag is determined by the iNode, size of your file, and the last modified time. When ever the eTag has been changed, it will download again. No, otherwise. So you probably need not the worry about this if you have found a properly (normal) host :)

Link to comment
Share on other sites

[...] I'll have a dig when I can about how to do this in IIS.
Finally got a chance to have a quick look at this: in IIS Manager, if you right-click any file in the site and choose Properties, then on the HTTP Headers tab you can set expiration for that file. Looks pretty simple to do in IIS then...
Link to comment
Share on other sites

if the server is set up properly, they will send a head consist of eTag for every resources, html, php, images are no exceptions. The eTag is determined by the iNode, size of your file, and the last modified time. When ever the eTag has been changed, it will download again. No, otherwise. So you probably need not the worry about this if you have found a properly (normal) host :)
If the host allows .htaccess files to begin with, you can disable ETags with
FileETag None

in the .htaccess file, and then enable expiration for caching's sake.

Finally got a chance to have a quick look at this: in IIS Manager, if you right-click any file in the site and choose Properties, then on the HTTP Headers tab you can set expiration for that file. Looks pretty simple to do in IIS then...
Just curious, does IIS somehow allow you to set up the expiration by type or for all files in a folder or... let's just sum it up with "does it have the flexibility of Apache?".
Link to comment
Share on other sites

[...] Just curious, does IIS somehow allow you to set up the expiration by type or for all files in a folder or... let's just sum it up with "does it have the flexibility of Apache?".
This is not an area I've gone into deeply myself (yet). But what I did find out is that you can specify HTTP headers at two levels:- the entire site- an item within the site (file or folder)At either of those levels, you can explicitly set expiration, and/or add custom headers. THe custom headers are name/value pairs, and this may, for all I know, include finer-grained expiration control such as file type or wildcard filename patterns.Apache. Must look at that myself sometime... the usual zero-cost lure of open source software is less straightforward for me, as the nature of my work means I'm an MSDN subscriber, and having paid that bill, all the MS stuff is "freely" available to me anyway! But zero cost is not the only lure, and I know there's a lot of good open source stuff out there if only you find time to learn it and get set up using it... and actually (on a slight tangent) I recently did just that with Asterisk Now (the open source Linux-based software PBX) and very pleased I am too with it. The telephones in my home/office environment are now all VOIP handsets, connected to the Asterisk PBX over the LAN, and can make/receive either VOIP calls or landline calls (via either of my two two landlines), call each other, and have their own voicemail, to name but a few features (as they are extensions on the PBX). Asterisk is entirely configurable by writing macros/code in config files, and you can do almost anything with custom ring groups or whatever you want. Fun! (if you like that kind of thing) :)
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...