Project

General

Profile

Is there a way to add an 'Expires' header?

Added by Sev Ax almost 14 years ago

Hi,

my problem is the long load time , due to a bunch of image files.

I was advised to add an Expires header , but is it possible to do this with the WT webserver?

If yes, how should I proceed?

Thank you !


Replies (4)

RE: Is there a way to add an 'Expires' header? - Added by Wim Dumon almost 14 years ago

Hi,

Wt adds Expires headers for all statically served files, except for internet explorer. A comment in the source code indicates that adding those headers for IE make it cache less.

Wim.

RE: Is there a way to add an 'Expires' header? - Added by Sev Ax almost 14 years ago

Thank you Wim.

I will try to broaden the matter a little , maybe this will shed more light to it.

The first time the page loads, I can see in Firebug that all 40 images are downloaded with status 200 (OK).

The next time the page loads, the images are not downloaded, instead a 304 (Not Modified) is returned for each one and their cached version is used.

Still, I would like to skip thosee 40 GET requests, even though nothing is downloaded, because the request resolution itself increases the page load time. I was told that this can be done by setting the Expires header for the images to a future date (The images will most probably never change). This way the browser would always use the cached images.

Is this possible/easy to do ? Or is there any other workaround?

Thank you

RE: Is there a way to add an 'Expires' header? - Added by Wim Dumon almost 14 years ago

Wt adds an expires header of 1 month in the future for statically served files. Can you check if these are present by expanding the requests you see in Firebug? Note that if you press reload in firefox, it does contact the server to reload files.

But to answer your base question: wthttpd is not the most flexible server to serve static files, and this is something you cannot do. For more flexibility, use a different web server, e.g. just to serve the static files.

Wim.

RE: Is there a way to add an 'Expires' header? - Added by Sev Ax almost 14 years ago

I can verify that the Expires header is set to 1 month in the future. Also, I have been wrong in claiming that the image files are requested again : they are not, except for when the Reload button is pressed, which probably requests everything from the server again deliberately.

It appears that the non-static content is taking some time to be generated and this I will try to optimize in my app..

Thanks , your help is much appreciated !

    (1-4/4)