Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. backend nginx {
  2. .host = "127.0.0.1";
  3. .port = "8008";
  4. }
  5.  
  6. sub vcl_recv {
  7. // Strip cookies for static files:
  8. if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
  9. unset req.http.Cookie;
  10. return(lookup);
  11. }
  12. }
  13.  
  14. sub vcl_hash {
  15. if (req.http.Cookie) {
  16. set req.hash += req.http.Cookie;
  17. }
  18. }
  19.  
  20. sub vcl_fetch {
  21.  
  22. // Strip cookies for static files:
  23. if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
  24. unset beresp.http.set-cookie;
  25. }
  26.  
  27. // Varnish determined the object was not cacheable
  28. if (!beresp.cacheable) {
  29. set beresp.http.X-Cacheable = "NO:Not Cacheable";
  30. }
  31.  
  32. // You don't wish to cache content for logged in users
  33. elsif(req.http.Cookie ~"(UserID|_session)") {
  34. set beresp.http.X-Cacheable = "NO:Got Session";
  35. return(pass);
  36. }
  37.  
  38. // You are respecting the Cache-Control=private header from the backend
  39. elsif ( beresp.http.Cache-Control ~ "private") {
  40. set beresp.http.X-Cacheable = "NO:Cache-Control=private";
  41. return(pass);
  42. }
  43.  
  44. // You are extending the lifetime of the object artificially
  45. elsif ( beresp.ttl < 1s ) {
  46. set beresp.ttl = 300s;
  47. set beresp.grace = 300s;
  48. set beresp.http.X-Cacheable = "YES:Forced";
  49. }
  50.  
  51. // Varnish determined the object was cacheable
  52. else {
  53. set beresp.http.X-Cacheable = "YES";
  54. }
  55.  
  56. return(deliver);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement