@@ -127,54 +127,54 @@ that will invalidate the cache for a given resource:
127
127
You must protect the ``PURGE `` HTTP method somehow to avoid random people
128
128
purging your cached data. You can do this by setting up an access list:
129
129
130
- .. code-block :: text
131
- /*
132
- Connect to the backend server
133
- on the local machine on port 8080
134
- */
135
- backend default {
136
- .host = "127.0.0.1";
137
- .port = "8080";
138
- }
130
+ .. code-block :: text
139
131
140
- // Acl's can contain IP's, subnets and hostnames
141
- acl purge {
142
- "localhost";
143
- "192.168.55.0"/24;
144
- }
132
+ /*
133
+ Connect to the backend server
134
+ on the local machine on port 8080
135
+ */
136
+ backend default {
137
+ .host = "127.0.0.1";
138
+ .port = "8080";
139
+ }
145
140
146
- sub vcl_recv {
147
- // Match PURGE request to avoid cache bypassing
148
- if (req.request == "PURGE") {
149
- // Match client IP to the acl
150
- if (!client.ip ~ purge) {
151
- // Deny access
152
- error 405 "Not allowed.";
153
- }
154
- // Perform a cache lookup
155
- return(lookup);
141
+ // Acl's can contain IP's, subnets and hostnames
142
+ acl purge {
143
+ "localhost";
144
+ "192.168.55.0"/24;
156
145
}
157
- }
158
-
159
- sub vcl_hit {
160
- // Match PURGE request
161
- if (req.request == "PURGE") {
162
- // Force object expiration for Varnish < 3.0
163
- set obj.ttl = 0s;
164
- // Do an actual purge for Varnish >= 3.0
165
- // purge;
166
- error 200 "Purged";
146
+
147
+ sub vcl_recv {
148
+ // Match PURGE request to avoid cache bypassing
149
+ if (req.request == "PURGE") {
150
+ // Match client IP to the acl
151
+ if (!client.ip ~ purge) {
152
+ // Deny access
153
+ error 405 "Not allowed.";
154
+ }
155
+ // Perform a cache lookup
156
+ return(lookup);
157
+ }
167
158
}
168
- }
169
159
170
- sub vcl_miss {
171
- // Match PURGE request
172
- if (req.request == "PURGE") {
173
- // Indicate that the object isn't stored in cache
174
- error 404 "Not purged";
160
+ sub vcl_hit {
161
+ // Match PURGE request
162
+ if (req.request == "PURGE") {
163
+ // Force object expiration for Varnish < 3.0
164
+ set obj.ttl = 0s;
165
+ // Do an actual purge for Varnish >= 3.0
166
+ // purge;
167
+ error 200 "Purged";
168
+ }
175
169
}
176
- }
177
170
171
+ sub vcl_miss {
172
+ // Match PURGE request
173
+ if (req.request == "PURGE") {
174
+ // Indicate that the object isn't stored in cache
175
+ error 404 "Not purged";
176
+ }
177
+ }
178
178
179
179
.. _`Edge Architecture` : http://www.w3.org/TR/edge-arch
180
180
.. _`GZIP and Varnish` : https://www.varnish-cache.org/docs/3.0/phk/gzip.html
0 commit comments