Skip to content

Instantly share code, notes, and snippets.

@rezan
Last active July 6, 2016 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rezan/ad5642ce12125eb553904c94c620b480 to your computer and use it in GitHub Desktop.
Save rezan/ad5642ce12125eb553904c94c620b480 to your computer and use it in GitHub Desktop.
Cedexis test objects local in Varnish Cache
/*
* Cedexis test object location: L34, L39
*
* Requires vmod null:
* https://github.com/varnish/libvmod-null
*
*/
vcl 4.0;
import std;
import null;
backend default
{
.host = "0.0.0.0";
.port = "80";
}
sub vcl_recv
{
if (req.url == "/cedexis/r20.gif") {
return (synth(781));
} else if (req.url == "/cedexis/r20-100KB.png") {
return (synth(782));
}
}
sub vcl_synth
{
if (resp.status == 781) {
set resp.status = 200;
set resp.http.Content-Type = "image/gif";
null.synth(std.fileread("/some/path/r20.gif"), 43);
return (deliver);
} else if (resp.status == 782) {
set resp.status = 200;
set resp.http.Content-Type = "image/png";
null.synth(std.fileread("/some/path/r20-100KB.png"), 102400);
return (deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment