Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-file
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-file
Commits
9d22f49d
Commit
9d22f49d
authored
Feb 28, 2021
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More detailed Last-Modified/I-M-S example for .mtime().
parent
29605c02
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
6 deletions
+52
-6
README.rst
README.rst
+26
-3
vmod_file.vcc
src/vmod_file.vcc
+26
-3
No files found.
README.rst
View file @
9d22f49d
...
...
@@ -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():
...
...
src/vmod_file.vcc
View file @
9d22f49d
...
...
@@ -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()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment