SSI and expires header

James Lee list at oxdrove.co.uk
Wed Jul 4 09:56:02 UTC 2012


On 25/06/12, 15:12:58, "Markus Jelsma" <markus.jelsma at openindex.io> wrote
regarding SSI and expires header:

Hello,

> We use SSI for serving a specific file but we want it to be cached
> by the clients for a few hours. We know SSI removes the Expires
> header set by the standard headers module so

SSI + expires works for me, example below.


> The browser, however, doesn't seem to cache the object so we must do
> something wrong here. I assume we also need a LastModified header
> but how can we force to send that header while SSI is on?


    location /ssi/ {
        ssi on;
        expires 1w;
        add_header Last-Modified 'not added';
    }
    location /ssi-with-last-modified/ {
        proxy_pass        http://localhost/ssi/;
        proxy_set_header  Host www.HOST.co.uk;
        add_header Last-Modified 'this works!';
    }



$ curl -I http://www.HOST.co.uk/ssi/
HTTP/1.1 200 OK
Server: nginx/1.2.2
Date: Wed, 04 Jul 2012 09:44:28 GMT
Content-Type: text/html; charset=8858-1
Connection: keep-alive
Vary: Accept-Encoding
Expires: Wed, 11 Jul 2012 09:44:28 GMT
Cache-Control: max-age=604800

$ curl -I http://www.HOST.co.uk/ssi-with-last-modified/
HTTP/1.1 200 OK
Server: nginx/1.2.2
Date: Wed, 04 Jul 2012 09:44:38 GMT
Content-Type: text/html; charset=8858-1
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Expires: Wed, 11 Jul 2012 09:44:38 GMT
Cache-Control: max-age=604800
Last-Modified: this works!





James.



More information about the nginx mailing list