-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimitlessv-nginx.tmpl
171 lines (162 loc) · 5.56 KB
/
limitlessv-nginx.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
###################################################################################################
# wp-limitlessv-nginx-cache:
# Is a NGINX configuration to speedup your WordPress
# website with or without cache plugin will benefit from it.
#
# Author: Shmuel Maruani
# URL: https://github.com/LimitlessVirtue/wp-limitlessv-nginx-cache/
#
# Tested with:
# - Clean no Cache plugin
# - WP Super Cache
# - W3 Total Cache
# - WP Fastest Cache
# - WP-Optimize
# - Autoptimize
# [WordPress NGINX](https://bitnami.com/stack/wordpress-pro)
###################################################################################################
# Version 0.0.1
###################################################################################################
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache uris containing the following segments
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)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged-in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+
|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
###################################################################################################
# BROWSER CACHE: fonts
#
location ~* \.(?:woff|woff2)$ {
etag on;
gzip_vary on;
expires 3M;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
}
###################################################################################################
# BROWSER CACHE: audio
#
location ~* \.(?:mp3|ra|oga)$ {
etag on;
gzip_vary on;
expires 4M;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
}
###################################################################################################
# BROWSER CACHE: video
#
location ~* \.(?:mpeg|mpg|mov|flv|avi|wmv|asx|asf|mng|ogv)$ {
etag on;
gzip_vary on;
expires 4M;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
# add_header Vary "Accept-Encoding, Cookie";
}
###################################################################################################
# BROWSER CACHE: images
#
location ~* \.(?:wbmp|jng|ico|png|jpeg|jpg|gif|cur)$ {
etag on;
gzip_vary on;
expires 2M;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
# add_header Vary "Accept-Encoding, Cookie";
}
###################################################################################################
# BROWSER CACHE: others
#
location ~* \.(?:swf|ogx|pdf)$ {
etag on;
gzip_vary on;
expires 2M;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
# add_header Vary "Accept-Encoding, Cookie";
}
###################################################################################################
# BROWSER CACHE: text
#
location ~* \.(?:xml|txt|rss|htc|mml)$ {
etag on;
gzip_vary on;
expires 1d;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
# add_header Vary "Accept-Encoding, Cookie";
}
###################################################################################################
# BROWSER CACHE: text/htm
#
location ~* \.(?:html|htm|shtml)$ {
etag on;
gzip_vary on;
expires 1d;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
# add_header Vary "Accept-Encoding, Cookie";
}
###################################################################################################
# BROWSER CACHE: text/style
#
location ~* \.css$ {
etag on;
gzip_vary on;
expires 1d;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
# add_header Vary "Accept-Encoding, Cookie";
}
###################################################################################################
# BROWSER CACHE: text/js
#
location ~* \.js$ {
etag on;
gzip_vary on;
expires 1d;
add_header Cache-Control "public";
# add_header Cache-Control "public, includeSubDomains";
# add_header Vary "Accept-Encoding, Cookie";
}
###################################################################################################
## This section, design to adding specific parameters base on the WordPress cache plugin.
###################################################################################################
location ~* /wp-content/cache/autoptimize/.*html$ {
etag on;
gzip_vary on;
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
#############
location ~* /wp-content/cache/autoptimize/css/.*css$ {
etag on;
gzip_vary on;
expires 7d;
add_header Cache-Control "public, includeSubDomains";
# add_header Cache-Control "public, includeSubDomains; preload";
# add_header Cache-Control "public";
}
#############
location ~* /wp-content/cache/autoptimize/js/.*js$ {
etag on;
gzip_vary on;
expires 7d;
add_header Cache-Control "public, includeSubDomains";
# add_header Cache-Control "public, includeSubDomains; preload";
# add_header Cache-Control "public";
}