tanim

Default VCL File

Jan 20th, 2014
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. # Default backend definition. Set this to point to your content server.
  2.  
  3. backend default {
  4. .host = "127.0.0.1";
  5. .port = "8080";
  6. .connect_timeout = 60s;
  7. .first_byte_timeout = 60s;
  8. .between_bytes_timeout = 60s;
  9. .max_connections = 800;
  10. }
  11.  
  12. acl purge {
  13. "127.0.0.1";
  14. "localhost";
  15. }
  16.  
  17. sub vcl_recv {
  18. set req.grace = 2m;
  19.  
  20. # Set X-Forwarded-For header for logging in nginx
  21. remove req.http.X-Forwarded-For;
  22. set req.http.X-Forwarded-For = client.ip;
  23.  
  24. # Remove has_js and CloudFlare/Google Analytics __* cookies and statcounter is_unique
  25. set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js|is_unique)=[^;]*", "");
  26. # Remove a ";" prefix, if present.
  27. set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
  28.  
  29. # Either the admin pages or the login
  30. if (req.url ~ "/wp-(login|admin|cron)") {
  31. # Don't cache, pass to backend
  32. return (pass);
  33. }
  34.  
  35. # Remove the wp-settings-1 cookie
  36. set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "")
  37. ;
  38.  
  39. # Remove the wp-settings-time-1 cookie
  40. set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");
  41.  
  42. # Remove the wp test cookie
  43. set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(;)?", "");
  44.  
  45. # Static content unique to the theme can be cached (so no user uploaded images)
  46. # The reason I don't take the wp-content/uploads is because of cache size on bigger blogs
  47. # that would fill up with all those files getting pushed into cache
  48. if (req.url ~ "wp-content/themes/" && req.url ~ "\.(css|js|png|gif|jp(e)?g)") {
  49. unset req.http.cookie;
  50. }
  51.  
  52. # Even if no cookies are present, I don't want my "uploads" to be cached due to their potential size
  53. if (req.url ~ "/wp-content/uploads/") {
  54. return (pass);
  55. }
  56.  
  57. # any pages with captchas need to be excluded
  58. if (req.url ~ "^/contact/" || req.url ~ "^/links/domains-for-sale/")
  59. {
  60. return(pass);
  61. }
  62.  
  63. # Check the cookies for wordpress-specific items
  64. if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") {
  65. # A wordpress specific cookie has been set
  66. return (pass);
  67. }
  68.  
  69. # allow PURGE from localhost
  70. if (req.request == "PURGE") {
  71. if (!client.ip ~ purge) {
  72. error 405 "Not allowed.";
  73. }
  74. return (lookup);
  75. }
  76.  
  77. # Force lookup if the request is a no-cache request from the client
  78. if (req.http.Cache-Control ~ "no-cache") {
  79. return (pass);
  80. }
  81.  
  82. # Try a cache-lookup
  83. return (lookup);
  84.  
  85. }
  86.  
  87. sub vcl_fetch {
  88. #set obj.grace = 5m;
  89. set beresp.grace = 2m;
  90.  
  91. }
  92.  
  93. sub vcl_hit {
  94. if (req.request == "PURGE") {
  95. purge;
  96. error 200 "Purged.";
  97. }
  98. }
  99.  
  100. sub vcl_miss {
  101. if (req.request == "PURGE") {
  102. purge;
  103. error 200 "Purged.";
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment