This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Nginx Config
cjhaas edited this page Feb 28, 2017
·
1 revision
Here's the general configuration for Nginx.
# BEGIN VENDI CACHE CODE #Match on gzip first because ordering matters. location ~ "/wp-content/vendi_cache/.*gzip$" { gzip off; types {} default_type text/html; add_header Vary "Accept-Encoding, Cookie"; add_header Content-Encoding gzip; } #If the previous matched, the following location won't be executed. location ~ /wp-content/vendi_cache/.* { add_header Vary "Accept-Encoding, Cookie"; } set $vendiCacheOn 1; #Don't cache form submissions. if ($request_method = POST) { set $vendiCacheOn 0; } #Allow caching of /?123=123 because this is a common DDoS to override caches. if ($query_string !~ "^(?:\d+=\d+)?$") { set $vendiCacheOn 0; } #Only cache URL's ending in / if ($request_uri !~ \/$) { set $vendiCacheOn 0; } #Don't cache any cookies with this in their names e.g. users who are logged in. if ($http_cookie ~* "(comment_author|wp\-postpass|wf_logout|wordpress_logged_in|wptouch_switch_toggle|wpmp_switcher)") { set $vendiCacheOn 0; } set $vendiCacheEncoding ""; #Oh, you want gzipped content? if ($http_accept_encoding ~ gzip) { set $vendiCacheEncoding _gzip; } set $vendiCacheHTTPS ""; if ($scheme = 'https'){ #If you want to ENABLE HTTPS caching, comment out the next line. #set $vendiCacheOn 0; #Comment this line out to enable HTTPS caching. set $vendiCacheHTTPS '_https'; #Uncomment this line to enable HTTPS caching. } #The main purpose of this line is to capture the URL components into variables. if ($request_uri !~ "^\/*(?[^\/]*)\/*(?[^\/]*)\/*(?[^\/]*)\/*(?[^\/]*)\/*(?[^\/]*)(?.*)$"){ # set $vendiCacheOn 0; } #If the file doesn't exist then don't serve from cache. if (!-f "$document_root/wp-content/vendi_cache/${http_host}_${wfone}/${wftwo}~${wfthree}~${wffour}~${wffive}~${wfsix}_vendi_cache${vendiCacheHTTPS}.html${vendiCacheEncoding}") { set $vendiCacheOn 0; } if ($vendiCacheOn = 1) { rewrite .* "/wp-content/vendi_cache/${http_host}_${wfone}/${wftwo}~${wfthree}~${wffour}~${wffive}~${wfsix}_vendi_cache${vendiCacheHTTPS}.html${vendiCacheEncoding}" last; } # END VENDI CACHE CODE