Advertisement
aka40

w3total nginx

Jan 25th, 2014
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. set $cache_uri $request_uri;
  2.  
  3. # POST requests and urls with a query string should always go to PHP
  4. if ($request_method = POST) {
  5. set $cache_uri 'null cache';
  6. }
  7. if ($query_string != "") {
  8. set $cache_uri 'null cache';
  9. }
  10.  
  11. # Don't cache uris containing the following segments
  12. if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
  13. set $cache_uri 'null cache';
  14. }
  15.  
  16. # Don't use the cache for logged in users or recent commenters
  17. if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
  18. set $cache_uri 'null cache';
  19. }
  20.  
  21. # Use cached or actual file if they exists, otherwise pass request to WordPress
  22. location / {
  23. try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args ;
  24. }
  25.  
  26. location ~ ^/wp-content/cache/minify/[^/]+/(.*)$ {
  27. try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
  28. }
  29.  
  30. location = /favicon.ico { log_not_found off; access_log off; }
  31. location = /robots.txt { log_not_found off; access_log off; }
  32.  
  33. location ~ .php$ {
  34. try_files $uri /index.php;
  35. include fastcgi_params;
  36. fastcgi_pass unix:/var/run/php5-fpm.sock;
  37. }
  38.  
  39. # Cache static files for as long as possible
  40. location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
  41. expires max; log_not_found off; access_log off;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement