Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- header('Cache-Control: public, s-maxage=300');
- ?>
- <!doctype html>
- <html>
- <head><title>Varnish test</title></head>
- <body>
- <h1>Varnish ESI test</h1>
- </pre>
- <hr>
- <p><?php echo microtime(true); ?> should not be equal to :</p>
- <esi:include src="/esi.php" />
- <hr>
- <?php
- header('Cache-Control: private');
- header('Cache-Control: maxage="0"');
- header('Cache-Control: s-maxage="0"');
- header('Pragma: no-cache');
- echo microtime(true);
- ?>
- <br>which should not be cached and greater than the other!
- sub vcl_recv {
- set req.http.X-Xunset = "";
- set req.http.X-Esi-Level="";
- #SYMFONY ESI
- set req.http.Surrogate-Capability = "abc=ESI/1.0";
- if (req.url ~ "esi.php"){
- return (pass);
- }
- if (req.url ~ "page.php"){
- # unset req.http.Cookie;
- set req.http.X-Xunset = "unset";
- return (hash);
- }
- }
- sub vcl_backend_response {
- set beresp.do_esi = true;
- if(bereq.http.X-Xunset == "unset" ){
- set beresp.http.X-Xunset = "unset";
- unset beresp.http.set-cookie;
- return(deliver);
- }
- }
- sub vcl_deliver {
- if (resp.http.x-varnish ~ " ") {
- set resp.http.x-cache = "HIT";
- } else {
- set resp.http.x-cache = "MISS";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement