bloodcult

WP Supercache Ngnix

Feb 26th, 2021
730
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### PLESK
  2. ### Domain Setting -> Apache & nginx Settings
  3. ### Unten “Additional nginx directives“
  4.  
  5.  
  6. ### WP Super Cache Below ###
  7. set $cache_uri $request_uri;
  8.  
  9. # POST requests and urls with a query string should always go to PHP
  10. if ($request_method = POST) {
  11.     set $cache_uri 'null cache';
  12. }
  13.  
  14. # GZIP Compression
  15. gzip on;
  16. gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
  17. gzip_min_length 1100;
  18. gzip_buffers 4 32k;
  19. gzip_proxied any;
  20. gzip_comp_level 9;
  21. gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
  22. gzip_vary on;
  23.  
  24. # NGINX Caching
  25. location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff)$ {
  26.     expires 14d;
  27.     add_header Cache-Control "public, no-transform";
  28.     log_not_found off;
  29. }
  30.  
  31. location ~* \.(jpg|jpeg|gif|png)$ {
  32.     expires 14d;
  33.     add_header Cache-Control "public, no-transform";
  34.     log_not_found off;
  35. }
  36.  
  37. location ~* \.(pdf|css|html|js|swf)$ {
  38.     expires 14d;
  39.     add_header Cache-Control "public, no-transform";
  40.     log_not_found off;
  41. }
  42.  
  43. location ~ \.css {
  44.     add_header  Content-Type    text/css;
  45. }
  46. location ~ \.js {
  47.     add_header  Content-Type    application/x-javascript;
  48. }
  49.  
  50. if ($query_string != "") {
  51.     set $cache_uri 'null cache';
  52. }
  53.  
  54. # Don't cache uris containing the following segments
  55. 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)") {
  56.     set $cache_uri 'null cache';
  57. }
  58.  
  59. # Don't use the cache for logged in users or recent commenters
  60. if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
  61.     set $cache_uri 'null cache';
  62. }
  63.  
  64. # Use cached or actual file if they exists, otherwise pass request to WordPress
  65. location ~ / {
  66.     try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;
  67. }
  68.  
  69. # WORDPRESS PERMALINKS
  70. if (!-e $request_filename) {
  71.     rewrite ^(.+)$ /index.php?q=$1 last;
  72. }
  73.  
  74. # SECURITY
  75. location ~* wp-config.php { deny all; }
  76. location ~* "^/wp-content/(?!plugins/).*\.php" { deny all; }
  77.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×