7
7
# Author: Maxime Jobin
8
8
# URL: https://github.com/maximejobin/rocket-nginx
9
9
#
10
- # Tested with WP-Rocket version: 2.5.6
11
- # Tested with NGINX: 1.6.3 (stable)
10
+ # Tested with WP-Rocket version: 2.5.11
11
+ # Tested with NGINX: 1.8.0 (stable)
12
12
#
13
- # Version 0.3
13
+ # Version 1.0
14
14
#
15
15
###################################################################################################
16
16
@@ -24,6 +24,7 @@ set $rocket_encryption ""; # Is GZIP accepted by client ?
24
24
set $rocket_file ""; # Filename to use
25
25
set $rocket_is_bypassed "No"; # Header text added to check if the bypass worked or not. Header: X-Rocket-Nginx-Bypass
26
26
set $rocket_reason ""; # Reason why cache file was not used. If cache file is used, what file was used
27
+ set $https_prefix "";
27
28
28
29
29
30
###################################################################################################
@@ -35,8 +36,13 @@ if ($http_accept_encoding ~ gzip) {
35
36
set $rocket_encryption "_gzip";
36
37
}
37
38
39
+ # Is SSL request ?
40
+ if ($https = "on") {
41
+ set $https_prefix "-https";
42
+ }
43
+
38
44
# File/URL to return IF we must bypass WordPress
39
- set $rocket_url "/wp-content/cache/wp-rocket/$http_host/$request_uri/index.html$rocket_encryption";
45
+ set $rocket_url "/wp-content/cache/wp-rocket/$http_host/$request_uri/index$https_prefix .html$rocket_encryption";
40
46
set $rocket_file "$document_root$rocket_url";
41
47
42
48
@@ -82,19 +88,20 @@ if ($rocket_bypass = 1) {
82
88
if ($rocket_debug = 0) {
83
89
set $rocket_is_bypassed "";
84
90
set $rocket_reason "";
91
+ set $rocket_file "";
85
92
}
86
93
87
94
# If the bypass token is still on, rewrite according to the file linked to the request
88
95
if ($rocket_bypass = 1) {
89
96
rewrite .* "$rocket_url" last;
90
97
}
91
98
92
-
93
99
# Add header to HTML cached files
94
100
location ~ /wp-content/cache/wp-rocket/.*html$ {
95
101
add_header Vary "Accept-Encoding, Cookie";
96
102
add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
97
103
add_header X-Rocket-Nginx-Reason $rocket_reason;
104
+ add_header X-Rocket-Nginx-File $rocket_file;
98
105
expires 30d;
99
106
}
100
107
@@ -107,9 +114,15 @@ location ~ /wp-content/cache/wp-rocket/.*_gzip$ {
107
114
add_header Vary "Accept-Encoding, Cookie";
108
115
add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
109
116
add_header X-Rocket-Nginx-Reason $rocket_reason;
117
+ add_header X-Rocket-Nginx-File $rocket_file;
110
118
expires 30d;
111
119
}
112
120
121
+ # Debug header (when file is not cached)
122
+ add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
123
+ add_header X-Rocket-Nginx-Reason $rocket_reason;
124
+ add_header X-Rocket-Nginx-File $rocket_file;
125
+
113
126
114
127
###################################################################################################
115
128
# BROWSER CSS CACHE
@@ -132,6 +145,6 @@ location ~ /wp-content/cache/min/.*\.js$ {
132
145
###################################################################################################
133
146
# BROWSER MEDIA CACHE
134
147
#
135
- location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|ttf|ogg)$ {
148
+ location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|woff2| ttf|ogg)$ {
136
149
expires max;
137
150
}
0 commit comments