Website image caching with Apache

Posted by Piskvor on Stack Overflow See other posts from Stack Overflow or by Piskvor
Published on 2009-01-15T14:48:13Z Indexed on 2012/12/01 23:04 UTC
Read the original article Hit count: 189

Filed under:
|
|

How can I get static content on Apache to be {cached by browser} and not {checked for freshness {with every request}}?

I'm working on a website hosted on Apache webserver. Recently, I was testing something with headers (Content-Type for different types of content) and saw a lot of conditional requests for images. Example:

200 /index.php?page=1234&action=list
304 /favicon.ico
304 /img/logo.png
304 /img/arrow.png
(etc.)

Although the image files are static content and are cached by the browser, every time an user opens a page that links to them, they are conditionally requested, to which they send "304 Not Modified". That's good (less data transferred), but it means 20+ more requests with every page load (longer page load due to all those round-trips, even with Keep-Alive and pipelining enabled).

How do I tell the browser to keep the existing file and not check for newer version?

EDIT: the mod_expires method works, even with the favicon.

© Stack Overflow or respective owner

Related posts about apache

Related posts about mod-expires