Advertisement
Guest User

Untitled

a guest
Nov 19th, 2012
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. backend default {
  2. .host = "127.0.0.1";
  3. .port = "8888";
  4. .probe = {
  5. .request = "HEAD / HTTP/1.1"
  6. "Host: mylocalsite.co"
  7. "Connection: close";
  8. .timeout = 5s;
  9. .interval = 5s;
  10. }
  11. }
  12.  
  13. sub vcl_fetch {
  14. set beresp.ttl = 10m;
  15. unset beresp.http.Set-Cookie;
  16.  
  17. if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
  18. unset beresp.http.set-cookie;
  19. set beresp.ttl = 20m;
  20. } else {
  21. set beresp.do_esi = true;
  22. }
  23.  
  24. return(deliver);
  25. }
  26.  
  27. sub vcl_recv {
  28.  
  29.  
  30. # Either the admin pages or the login
  31. if (req.url ~ "/admin/?") {
  32. # Don't cache, pass to backend
  33. return (pass);
  34. }
  35.  
  36. # Remove the "has_js" cookie
  37. set req.http.Cookie = regsuball(req.http.Cookie, "has_js=[^;]+(; )?", "");
  38.  
  39. # Remove the "Drupal.toolbar.collapsed" cookie
  40. set req.http.Cookie = regsuball(req.http.Cookie, "Drupal.toolbar.collapsed=[^;]+(; )?", "");
  41.  
  42. # Remove any Google Analytics based cookies
  43. set req.http.Cookie = regsuball(req.http.Cookie, "__utm.=[^;]+(; )?", "");
  44.  
  45. # Remove the Quant Capital cookies (added by some plugin, all __qca)
  46. set req.http.Cookie = regsuball(req.http.Cookie, "__qc.=[^;]+(; )?", "");
  47.  
  48. set req.http.Cookie = regsuball(req.http.Cookie, "__qca=[^;]+(; )?", "");
  49.  
  50. set req.http.Cookie = regsuball(req.http.Cookie, "_chartbeat2=[^;]+(; )?", "");
  51.  
  52. set req.http.Cookie = regsuball(req.http.Cookie, "Drupal.tableDrag.showWeight=[^;]+(; )?", "");
  53.  
  54. set req.http.Cookie = regsuball(req.http.Cookie, "undefined=[^;]+(; )?", "");
  55.  
  56. set req.http.Cookie = ";" + req.http.Cookie;
  57. set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
  58. set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|NO_CACHE)=", "; \1=");
  59. set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
  60. set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
  61.  
  62. // Remove has_js and Google Analytics __* cookies.
  63. set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(__[a-z]+|has_js)=[^;]*", "");
  64. // Remove a ";" prefix, if present.
  65. set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
  66.  
  67. # Are there cookies left with only spaces or that are empty?
  68. if (req.http.cookie ~ "^ *$") {
  69. unset req.http.cookie;
  70. }
  71.  
  72. # Anything else left?
  73. if (!req.http.cookie) {
  74. unset req.http.cookie;
  75. }
  76.  
  77. unset req.http.cookie;
  78.  
  79. }
  80.  
  81. sub vcl_deliver {
  82. if (obj.hits > 0) {
  83. set resp.http.X-Varnish-Cache = "HIT";
  84. }
  85. else {
  86. set resp.http.X-Varnish-Cache = "MISS";
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement