Cache control headers

Discussion in 'Apache' started by Eric Mann, Oct 25, 2007.

  1. #1
    Hi,
    I'm hosting a few images - where I'm required to dynamically watermark them. I achieve this by using mod_rewrite to rewrite the URL to a php page:
    RewriteRule    ^(.*)\.jpg$  watermark.php?filename=$1.jpg
    Code (markup):
    watermark.php just grabs the image and applies a quick watermark. All works fine, but I've noticed that apache gives slightly different headers:

    Header for a "real" image:
    Date: Thu, 25 Oct 2007 21:38:10 GMT
    Server: Apache/2.2.4 (Ubuntu) PHP/5.2.3-1ubuntu6
    Last-Modified: Mon, 15 Oct 2007 02:52:51 GMT
    Etag: "1a6888-430c-2a0f46c0"
    Accept-Ranges: bytes
    Content-Length: 17164
    Content-Type: image/jpeg
    
    200 OK
    Code (markup):
    Headers for a dynamic image:
    Date: Thu, 25 Oct 2007 21:37:38 GMT
    Server: Apache/2.2.4 (Ubuntu) PHP/5.2.3-1ubuntu6
    X-Powered-By: PHP/5.2.3-1ubuntu6
    Keep-Alive: timeout=15, max=99
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: image/jpeg
    
    200 OK
    Code (markup):
    The problem is, with the headers from the dynamic image - web browsers are not caching the images. And it's quite important in my site - that they do. Anyway I can get Apache to output the headers just like it would for a static image?

    Thanks.
    Eric.
     
    Eric Mann, Oct 25, 2007 IP