Advertisement
Fany_VanDaal

Vymazlení pro WP Super Cache 2

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