Welcome! Log In Create A New Profile

Advanced

Re: SSI and expires header

Brian Akins
July 04, 2012 09:12AM
On Jul 4, 2012, at 5:56 AM, James Lee wrote:
>
> 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!';
> }
>

With this config, every request will actually cause two hits to nginx.

Last-Modified is removed from SSI in every web server I know because you'd really need to show the last modified time of the newest included element. Also, if there are dynamic elements, how do you handle those?

I did simple Lua header filter that adds the current time to Last-Modified when needed. Depending on which browsers you need to support, however, just adding Expires and/or Cache-Control headers is enough to get the browser to cache. I know that not all browsers behave correctly, however.

Something simple like:

header_filter_by_lua '
ngx.header["Last-Modified"] = ngx.http_time(ngx.time())
';

Of course, you may want to check to see if it's already been set, only set if a flag is present, etc.


The "proxy to yourself" solution is unacceptable for a busy site.

--Brian_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

SSI and expires header

Markus Jelsma June 25, 2012 10:14AM

RE: SSI and expires header

Markus Jelsma June 26, 2012 07:34AM

Re: SSI and expires header

James Lee July 04, 2012 05:58AM

Re: SSI and expires header

Brian Akins July 04, 2012 09:12AM

RE: SSI and expires header

Markus Jelsma July 04, 2012 09:50AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 255
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready