Commit 9d22f49d authored by Geoff Simmons's avatar Geoff Simmons

More detailed Last-Modified/I-M-S example for .mtime().

parent 29605c02
......@@ -459,9 +459,32 @@ encountered an error.
Example::
# A VCL TIME is converted to a string as an HTTP date, and hence is
# suitable for the Last-Modified header.
set resp.http.Last-Modified = rdr.mtime();
# A VCL TIME is converted to a string as an HTTP date, so .mtime()
# is suitable for the Last-Modified header. If the If-Modified-Since
# request header is present and designates an earlier time than
# .mtime(), send a 304 Not Modified response.
import std;
sub vcl_recv {
# std.time() parses If-Modified-Since as a TIME. If the parse
# fails, fall back to now (which is almost certainly not earlier
# than the mtime).
if (std.time(req.http.If-Modified-Since, now) < rdr.mtime()) {
return (synth(304));
}
else {
return (synth(200));
}
}
sub vcl_synth {
set resp.http.Last-Modified = rdr.mtime();
if (resp.status == 200) {
rdr.synth();
}
return(deliver);
}
.. _xreader.next_check():
......
......@@ -421,9 +421,32 @@ encountered an error.
Example::
# A VCL TIME is converted to a string as an HTTP date, and hence is
# suitable for the Last-Modified header.
set resp.http.Last-Modified = rdr.mtime();
# A VCL TIME is converted to a string as an HTTP date, so .mtime()
# is suitable for the Last-Modified header. If the If-Modified-Since
# request header is present and designates an earlier time than
# .mtime(), send a 304 Not Modified response.
import std;
sub vcl_recv {
# std.time() parses If-Modified-Since as a TIME. If the parse
# fails, fall back to now (which is almost certainly not earlier
# than the mtime).
if (std.time(req.http.If-Modified-Since, now) < rdr.mtime()) {
return (synth(304));
}
else {
return (synth(200));
}
}
sub vcl_synth {
set resp.http.Last-Modified = rdr.mtime();
if (resp.status == 200) {
rdr.synth();
}
return(deliver);
}
$Method DURATION .next_check()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment