Jump to content

Will images cache when called absolutely?


TheFilmGod

Recommended Posts

There are a number of different headers you could use.

 

For instance, if you would like it cached for one month then you could do Expires: Tue, 22 Jul 2008 20:42:40 GMT and Cache-Control: max-age=2592000; must-revalidate (one month being 30 days here). Furthermore, keeping Last-Modified accurate and sending an ETag will also help. An ETag is simply, well... a tag. It changes each time the file changes and the client can then check by sending the ETag in a If-None-Match request header. If the ETag matches then the server will send an HTTP 304 Not Modified response header and the browser will then use the cached version instead. If I remember correctly, then ETags where introduced in HTTP 1.1.

 

A combination of the above might be the ideal solution.

Link to comment
Share on other sites

On a static HTML file on my VPS I received the following response headers:

 

HTTP/1.1 200 OK
Date: Sun, 22 Jun 2008 21:53:36 GMT
Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 PHP/5.2.0-8+etch11 mod_ssl/2.2.3 OpenSSL/0.9.8c
Last-Modified: Thu, 19 Jun 2008 09:44:58 GMT
ETag: "7a8aec-21a-d48c5a80"
Accept-Ranges: bytes
Content-Length: 538
Content-Type: text/html; charset=UTF-8

 

Note that the Last-Modified header was set to when I actually last modified it. Apache determines this by the last change time of the file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.