Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # Configuacao para apontamento para o Apache
  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_
  26. unique)=[^;]*", "");
  27. # Remove a ";" prefix, if present.
  28. set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
  29.  
  30. # Either the admin pages or the login
  31. if (req.url ~ "/wp-(login|admin|cron)") {
  32. # Don't cache, pass to backend
  33. return (pass);
  34. }
  35.  
  36. # Remove the wp-settings-1 cookie
  37. set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "")
  38. ;
  39.  
  40. # Remove the wp-settings-time-1 cookie
  41. set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?"
  42. , "");
  43.  
  44. # Remove the wp test cookie
  45. set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(;
  46. )?", "");
  47.  
  48. # Cache para os arquivos estaticos mas não para a pasta uploads, pois o tamanho pode ser grande
  49. if (req.url ~ "wp-content/themes/" && req.url ~ "\.(css|js|png|gif|jp(e)?g)") {
  50. unset req.http.cookie;
  51. }
  52.  
  53. # Nao cachear a pasta uploads
  54. if (req.url ~ "/wp-content/uploads/") {
  55. return (pass);
  56. }
  57.  
  58. # Paginas com captchas sao excluidas
  59. if (req.url ~ "^/contact/" || req.url ~ "^/links/domains-for-sale/")
  60. {
  61. return(pass);
  62. }
  63.  
  64. # Ignora o cache na presenca de cookies de administracao
  65. if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") {
  66. # A wordpress specific cookie has been set
  67. return (pass);
  68. }
  69.  
  70. # allow PURGE from localhost
  71. if (req.request == "PURGE") {
  72. if (!client.ip ~ purge) {
  73. error 405 "Not allowed.";
  74. }
  75. return (lookup);
  76. }
  77.  
  78. # Force lookup if the request is a no-cache request from the client
  79. if (req.http.Cache-Control ~ "no-cache") {
  80. return (pass);
  81. }
  82.  
  83. # Try a cache-lookup
  84. return (lookup);
  85.  
  86. }<code></code>
  87.  
  88. sub vcl_fetch {
  89. #set obj.grace = 5m;
  90. set beresp.grace = 2m;
  91.  
  92. }
  93.  
  94. sub vcl_hit {
  95. if (req.request == "PURGE") {
  96. purge;
  97. error 200 "Purged.";
  98. }
  99. }
  100.  
  101. sub vcl_miss {
  102. if (req.request == "PURGE") {
  103. purge;
  104. error 200 "Purged.";
  105. }
  106. }