Expiration date on Image files?

I don't know anything about JSP or Apache.  But you folks do!  So...

If you go to this page:
     http://www.google.com/
and then look at the IE6 cache files, you will see that the "Expiration Date" for the file named
      http://www.google.com/images/logo.gif
is set some time in the year 2038

But if you look at the cached GIF files that come in from this page
     http://www.experts-exchange.com
for instance,
      http://www.experts-exchange.com/images/logoBottom.gif
there is no expiration date.  

1) Why is that?
2) How can a site that uses JSP serve up a GIF file and specify an expiration date for it?

-- Dan
LVL 49
DanRollinsAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
kennethxuConnect With a Mentor Commented:
Sorry Dan, come back to the topic. I found that apache mod_expires does exactly what you are looking for. below will set expire one month later for all image files.

<Files ~ "\.(gif|jpe?g|png)$">
    ExpiresActive On
    ExpiresDefault "access plus 1 month"
</Files>

you can control in file, directory and/or location level. for more information:
http://httpd.apache.org/docs/mod/mod_expires.html
0
 
kennethxuCommented:
this is not something that jsp do, instead, you can use Filter to set a expiration header for gif files.
let me know if you need further information.
0
 
kennethxuCommented:
in filter you need:
response.setDateHeader ( "Expires ", datemillisecond );
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DanRollinsAuthor Commented:
Thanks!

Is that something that an Apache-savvy website admin would know how to do if I email that info to him?

...and...

Can he set the server to send that header on some GIFs but not others?

-- Dan
0
 
kennethxuCommented:
No, You need to develop a ServletFilter for your webapp. Apache is a web server, not jsp server (formally, called servlet container). do you know what jsp server are you using?
0
 
objectsCommented:
> 2) How can a site that uses JSP serve up a GIF file and specify an expiration date for it?

Use a servlet to serve up your image.
0
 
DanRollinsAuthor Commented:
I'm sorry, I'm a total idiot about these things... I'm just exploring a kookie idea I had that setting an Expiration Date to the distant future on seldom-changed image files might allow IE's cache to work more efficiently.

Has anyone ever checked into that?

-- Dan
0
 
objectsCommented:
Depends on your definition of more efficiently. If you take it to the extreme you could have a cache that stored everything it found, and never deleted anything, but the disk space requirements would increase until the disk was full.
0
 
DanRollinsAuthor Commented:
By efficiently I mean "so that the client (IE6) does not request the file from the server or even bother to make a round-trip to ask the server if it has changed."

-- Dan
0
 
objectsCommented:
It's a tradeoff between speed and disk space. As you cache more files, and for longer periods the disk space requirements increase.
0
 
DanRollinsAuthor Commented:
What I'm trying to do is avoid network traffic.
0
 
objectsCommented:
From a client perspective or server?

If from a client perspective then adjust the settings in your cache so it hangs onto files for longer for example by increasing its size, and purging it less often.
0
 
DanRollinsAuthor Commented:
Yes, but also from the host perspective.   I want to ensure that the client uses a cached image rather than asking the host to resend it or even asking the host if it needs to be resent.  

For porposes of this discussion, assume that the cache on the client has plenty of space available.
0
 
objectsCommented:
It depends on the clients cache settings.
0
 
DanRollinsAuthor Commented:
For purposes of this discussion, assume that the user's cache settings are set at the default, which is I believe,  

    Check for newer versions of stored pages:  Automatically

Which means:
   ...Over time if IE determines that the images on the page are changing
    infrequently it will check for newer images even less freqyently...

which to me, indicates that it *will* continue checking, at least sometimes.  And each "check" requires a roundtrip to the server.   Obviously, tiny GIF files for spacing or the corners of boxes, or button images -- never change.  So my theory is that if the SERVER sends an explicit caching instruction, that some network traffic could be avoided.
0
 
objectsCommented:
If you could (and I'm not sure you can), how would it handle if the resource *did* change at some point for whatever reason. If the browser never checked the server, then it would never download the updated resource.
0
 
DanRollinsAuthor Commented:
That would be my question to you... :)

But in that rare situation, where the site was completely redone,.... say once per century, I'd imagine that there would be a way to handle it... for instance, use different filenames for the new corner GIF files.   THery may be another cache-control mechanism at the page-level that would force a flush of the embedded file references.

-- Dan
0
 
objectsCommented:
> That would be my question to you... :)

It was a rhetorical q really:) If if clients supported the approach u suggest it would leave no way for a client to know to grab new resource.

> THery may be another cache-control mechanism at the page-level that would force a flush of the embedded file references

A little inconvenient.

> THery may be another cache-control mechanism at the page-level that would force a flush of the embedded file references

This would require the client to have this mechanism implemented which it doesn't.
0
 
DanRollinsAuthor Commented:
But the real reason is:  Google.com does it (set an "Expires" date far in the future) on their logo image file.   In general, the folks at google are not idiots, so there must be a mechanism or they (smart people that they are) must think that it's not too critical of an issue.
0
 
objectsCommented:
> Google.com does it

I think you'll find there is still some contact between client and server.

If you just want to set Expires then use a servlet or ServletFIlter to set it appropriately.
0
 
DanRollinsAuthor Commented:
Indeed, the ServletFilter sounds like the way to go (though it seems like it should be easier... like a generic server setting).  I wish I had some way to know for sure if it would make any difference to site load times.

Thanks for all of your help so far.  I'll leave tis open for a few days.

-- Dan
0
 
kennethxuCommented:
>>I'm just exploring a kookie idea I had that setting an Expiration Date to the distant future on seldom-changed image files might allow IE's cache to work more efficiently.

just for you info, ie only check if an image is change once in one browser session. it doesn't always. so the expire thing ONLY HELP on one conditional get request to server in one browser process life cycle. (unless user clear cache manually)
0
 
kennethxuCommented:
let me know if you need futher help on ServletFilter.
0
 
DanRollinsAuthor Commented:
Thanks kennethxu.
Can you identify an official Microsoft source that says that?  The only thing I found says that "it checks less frequently."

Assuming that it is true, my idea would only save the user a small amount of time... unless he closes the Browser (and thus ends the session).   There are enough EE user's complaining about too-long load-times that it may be possible that they are setting their caching options incorrectly, or are opening a new browser window with each EE email notification ...or something like that.

What's more, if 100,000 people log in 10 times per day, then that's 1,000,000 more times the server must needlessly handle a round trip for small GIF files that never change.  So it is still worth looking into, I think.

-- Dan
0
 
kennethxuCommented:
Hi Dan,

I'm sorry that I don't know if there is a MS doc state this. I doubt there is one. What I said is based on our experience with IE5.5/6. We check the server access log to observe the IE behavior.

Another thing that we have observed and might interest you is that IE will display the page before the images are downloaded. So if your page takes long time to load, it might not related to image. BTW, IE does need all css and js files for render the page.

I agree with you that a large amount small gif file worth looking into. I asked our apache expert about your Q. He said, you might want to look into mod_header. that will be more on configuration side comparing to Servlet Filter.

http://httpd.apache.org/docs/mod/mod_headers.html

Ken
0
 
objectsCommented:
WOuldn't the bevaviour depend on what the browser cache setting are?

> that IE will display the page before the images are downloaded

Thats right images are downloaded asynchonously.
0
 
kennethxuCommented:
>> WOuldn't the bevaviour depend on what the browser cache setting are?

Comment from DanRollins
Date: 03/27/2004 04:49PM PST
 Author Comment  


For purposes of this discussion, assume that the user's cache settings are set at the default, which is I believe,  

    Check for newer versions of stored pages:  Automatically
 
0
 
objectsCommented:
i was aware of that, the context of your comment just wasn't clear.
0
 
kennethxuCommented:
sorry object, I'm here to share, just don't have time to argue on pointless comments.
0
 
objectsCommented:
What argument??? I asked for a simple clarification of your comment.
0
 
kennethxuCommented:
and the clarification was given, what else do you want?
0
 
objectsCommented:
> what else do you want?

nothing, and I didn't ask u for anything so am not sure what u r carrying on about.
0
 
DanRollinsAuthor Commented:
Please stop this thread-polluting nonesense.  Thanks.
-- Dan
0
 
objectsCommented:
Sorry about that Dan.
0
 
DanRollinsAuthor Commented:
Though I am personally unable to test this, that looks like the ticket.  Thanks!
-- Dan
0
 
kennethxuCommented:
you are welcome and thank for the A grade.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.