Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. <?php
  2. session_start();
  3. header('Cache-Control: public, s-maxage=300');
  4. ?>
  5. <!doctype html>
  6. <html>
  7. <head><title>Varnish test</title></head>
  8. <body>
  9. <h1>Varnish ESI test</h1>
  10. </pre>
  11. <hr>
  12. <p><?php echo microtime(true); ?> should not be equal to :</p>
  13. <esi:include src="/esi.php" />
  14. <hr>
  15.  
  16. <?php
  17. header('Cache-Control: private');
  18. header('Cache-Control: maxage="0"');
  19. header('Cache-Control: s-maxage="0"');
  20. header('Pragma: no-cache');
  21. echo microtime(true);
  22. ?>
  23. <br>which should not be cached and greater than the other!
  24.  
  25. sub vcl_recv {
  26. set req.http.X-Xunset = "";
  27. set req.http.X-Esi-Level="";
  28.  
  29. #SYMFONY ESI
  30. set req.http.Surrogate-Capability = "abc=ESI/1.0";
  31. if (req.url ~ "esi.php"){
  32. return (pass);
  33. }
  34. if (req.url ~ "page.php"){
  35. # unset req.http.Cookie;
  36. set req.http.X-Xunset = "unset";
  37. return (hash);
  38. }
  39.  
  40. }
  41.  
  42. sub vcl_backend_response {
  43. set beresp.do_esi = true;
  44. if(bereq.http.X-Xunset == "unset" ){
  45. set beresp.http.X-Xunset = "unset";
  46. unset beresp.http.set-cookie;
  47. return(deliver);
  48. }
  49.  
  50. }
  51.  
  52. sub vcl_deliver {
  53. if (resp.http.x-varnish ~ " ") {
  54. set resp.http.x-cache = "HIT";
  55. } else {
  56. set resp.http.x-cache = "MISS";
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement