Varnish_Cache - Version 3.0.0

Version Notes

- Changed license to OSL for Community Edition
- Instantly purge cache items of CMS pages, categories and products on save
- Configure different TTLs per route/controller
- Use "Cache-Control:s-maxage=x" instead of propriatary headers to control Varnish
- Improved Magento EE compatibility
- Allow frontend Varnish caching while beeing logged in the backend
- Added design exceptions (beta)

Download this release

Release Info

Developer Magento Core Team
Extension Varnish_Cache
Version 3.0.0
Comparing to
See all releases


Version 3.0.0

Files changed (77) hide show
  1. README_VARNISH_CACHE.txt +420 -0
  2. app/code/community/Phoenix/VarnishCache/.DS_Store +0 -0
  3. app/code/community/Phoenix/VarnishCache/Block/.DS_Store +0 -0
  4. app/code/community/Phoenix/VarnishCache/Block/Adminhtml/.DS_Store +0 -0
  5. app/code/community/Phoenix/VarnishCache/Block/Adminhtml/Cache/.DS_Store +0 -0
  6. app/code/community/Phoenix/VarnishCache/Block/Adminhtml/Cache/Additional.php +74 -0
  7. app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/.DS_Store +0 -0
  8. app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/Config/.DS_Store +0 -0
  9. app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/Config/Fieldset/.DS_Store +0 -0
  10. app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/Config/Fieldset/RouteTTL.php +45 -0
  11. app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/Config/Fieldset/Versioninfo.php +39 -0
  12. app/code/community/Phoenix/VarnishCache/Helper/.DS_Store +0 -0
  13. app/code/community/Phoenix/VarnishCache/Helper/Cache.php +270 -0
  14. app/code/community/Phoenix/VarnishCache/Helper/Control/.DS_Store +0 -0
  15. app/code/community/Phoenix/VarnishCache/Helper/Control/Catalog/.DS_Store +0 -0
  16. app/code/community/Phoenix/VarnishCache/Helper/Control/Catalog/Category.php +45 -0
  17. app/code/community/Phoenix/VarnishCache/Helper/Control/Catalog/Product.php +45 -0
  18. app/code/community/Phoenix/VarnishCache/Helper/Control/Cms/.DS_Store +0 -0
  19. app/code/community/Phoenix/VarnishCache/Helper/Control/Cms/Page.php +45 -0
  20. app/code/community/Phoenix/VarnishCache/Helper/Data.php +87 -0
  21. app/code/community/Phoenix/VarnishCache/Model/.DS_Store +0 -0
  22. app/code/community/Phoenix/VarnishCache/Model/Catalog/.DS_Store +0 -0
  23. app/code/community/Phoenix/VarnishCache/Model/Catalog/Category/.DS_Store +0 -0
  24. app/code/community/Phoenix/VarnishCache/Model/Catalog/Category/Product.php +27 -0
  25. app/code/community/Phoenix/VarnishCache/Model/Catalog/Product/.DS_Store +0 -0
  26. app/code/community/Phoenix/VarnishCache/Model/Catalog/Product/Relation.php +27 -0
  27. app/code/community/Phoenix/VarnishCache/Model/Cms/.DS_Store +0 -0
  28. app/code/community/Phoenix/VarnishCache/Model/Cms/Page/.DS_Store +0 -0
  29. app/code/community/Phoenix/VarnishCache/Model/Cms/Page/Store.php +27 -0
  30. app/code/community/Phoenix/VarnishCache/Model/Control.php +135 -0
  31. app/code/community/Phoenix/VarnishCache/Model/Control/.DS_Store +0 -0
  32. app/code/community/Phoenix/VarnishCache/Model/Control/Abstract.php +97 -0
  33. app/code/community/Phoenix/VarnishCache/Model/Control/Catalog/.DS_Store +0 -0
  34. app/code/community/Phoenix/VarnishCache/Model/Control/Catalog/Category.php +76 -0
  35. app/code/community/Phoenix/VarnishCache/Model/Control/Catalog/Product.php +112 -0
  36. app/code/community/Phoenix/VarnishCache/Model/Control/Cms/.DS_Store +0 -0
  37. app/code/community/Phoenix/VarnishCache/Model/Control/Cms/Page.php +76 -0
  38. app/code/community/Phoenix/VarnishCache/Model/Observer.php +267 -0
  39. app/code/community/Phoenix/VarnishCache/Model/Processor.php +49 -0
  40. app/code/community/Phoenix/VarnishCache/Model/Resource/.DS_Store +0 -0
  41. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/.DS_Store +0 -0
  42. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/.DS_Store +0 -0
  43. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/.DS_Store +0 -0
  44. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/Product.php +31 -0
  45. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/Product/.DS_Store +0 -0
  46. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/Product/Collection.php +45 -0
  47. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Product/.DS_Store +0 -0
  48. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Product/Relation/.DS_Store +0 -0
  49. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Product/Relation/Collection.php +44 -0
  50. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/.DS_Store +0 -0
  51. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/Page/.DS_Store +0 -0
  52. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/Page/Store.php +31 -0
  53. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/Page/Store/.DS_Store +0 -0
  54. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/Page/Store/Collection.php +44 -0
  55. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Core/.DS_Store +0 -0
  56. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Core/Url/.DS_Store +0 -0
  57. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Core/Url/Rewrite/.DS_Store +0 -0
  58. app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Core/Url/Rewrite/Collection.php +36 -0
  59. app/code/community/Phoenix/VarnishCache/controllers/.DS_Store +0 -0
  60. app/code/community/Phoenix/VarnishCache/controllers/Adminhtml/.DS_Store +0 -0
  61. app/code/community/Phoenix/VarnishCache/controllers/Adminhtml/VarnishCacheController.php +57 -0
  62. app/code/community/Phoenix/VarnishCache/etc/.DS_Store +0 -0
  63. app/code/community/Phoenix/VarnishCache/etc/config.xml +256 -0
  64. app/code/community/Phoenix/VarnishCache/etc/default_2.1.vcl +223 -0
  65. app/code/community/Phoenix/VarnishCache/etc/default_3.0.vcl +230 -0
  66. app/code/community/Phoenix/VarnishCache/etc/system.xml +171 -0
  67. app/design/adminhtml/default/default/layout/varnishcache.xml +29 -0
  68. app/design/adminhtml/default/default/template/varnishcache/.DS_Store +0 -0
  69. app/design/adminhtml/default/default/template/varnishcache/cache/.DS_Store +0 -0
  70. app/design/adminhtml/default/default/template/varnishcache/cache/additional.phtml +50 -0
  71. app/etc/modules/Phoenix_VarnishCache.xml +29 -0
  72. app/etc/varnishcache.xml +30 -0
  73. app/locale/de_DE/Phoenix_VarnishCache.csv +42 -0
  74. app/locale/es_ES/Phoenix_VarnishCache.csv +41 -0
  75. app/locale/fr_FR/Phoenix_VarnishCache.csv +41 -0
  76. app/locale/nb_NO/Phoenix_VarnishCache.csv +41 -0
  77. package.xml +30 -0
README_VARNISH_CACHE.txt ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*******************************************************************************
2
+ *
3
+ * PageCache powered by Varnish – Documentation
4
+ *
5
+ * Copyright 2011 by PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.eu)
6
+ *
7
+ * "VARNISH" is a registered trademark of Varnish Software AB (http://www.varnish-software.com/)
8
+ * "Magento" is a registered trademark of Magento Inc. (http://www.magento.com)
9
+ *
10
+ ******************************************************************************/
11
+
12
+ Table of contents
13
+ =================
14
+
15
+ 1. Introduction
16
+ 2. Prerequisites
17
+ 3. Installation
18
+ 4. Configuration
19
+ 4.1 PageCache module
20
+ 4.2 Varnish Cache (VCL)
21
+ 5. Cache cleaning, PURGE requests
22
+ 6. Troubleshooting
23
+ 6.1 Known issues
24
+ 6.2 Prevent caching for custom modules
25
+ 6.3 Prevent caching for HTML/PHP files outsite Magento
26
+ 6.4 Debugging requests
27
+ 7. Changelog
28
+
29
+
30
+ 1. Introduction
31
+ ===============
32
+
33
+ Thank you for using PageCache powered by Varnish module. This package
34
+ contains everything you need to connect Varnish Cache with your
35
+ Magento Commerce shop and to get the most out of Varnish’s powerful
36
+ caching capabilities for a blazing fast eCommerce site.
37
+
38
+ The PageCache module has been architectural certified by Varnish
39
+ Software to ensure highest quality and reliability for Magento stores.
40
+ PHOENIX MEDIA is a Varnish Integration Partner and Magento Gold Partner
41
+ in Germany and Austria and is maintaining this module as well as providing
42
+ professional services for Varnish and Magento Commerce.
43
+
44
+ The PageCache powered by Varnish module consists of two main components:
45
+ The Magento module and the bundled Varnish Cache configuration file
46
+ (VCL). The PageCache module basically sets the correct Cache-Control
47
+ headers according to the configuration and the visitor session and provides
48
+ an interface for cleaning Varnish’s cache. The second component, the VCL,
49
+ configures Varnish to process the client requests and Magento’s HTML
50
+ response according to the Cache-Control headers the PageCache module adds
51
+ to every response.
52
+
53
+ Beside shop pages Varnish will also cache static contents that is
54
+ severed by the web server like product images, CSS or JavaScript files
55
+ or even flash or PDF resources. While you can also clean Varnish’s
56
+ static content cache from the Magento Cache Management page the
57
+ PageCache configuration won’t affect any of the static file’s HTTP
58
+ headers as they are directly served by the web server.
59
+
60
+
61
+ 2. Prerequisites
62
+ ================
63
+
64
+ Before installing the PageCache module you should setup a test hosting
65
+ environment as you will need to change the web server’s port
66
+ configuration and put Varnish in front which will certainly take a while
67
+ for configuring and testing. If you directly rollout this solution to
68
+ your production server you will certainly have down times which should
69
+ be prevented to not annoy your customers.
70
+
71
+ Ensure that your Magento Commerce shop is running without any problems
72
+ in your environment as debugging Magento issues with a proxy like
73
+ Varnish in front might be difficult.
74
+
75
+ PageCache powered by Varnish supports Magento Community Edition from
76
+ version 1.4 and Magento Professional/Enterprise Edition from version 1.7.0
77
+ on.
78
+
79
+ Furthermore you should have installed Varnish >= 2.1 on your Linux
80
+ server. To install Varnish Cache refer to the excellent documentation at
81
+ http://www.varnish-cache.org/docs/ where you will also find lots of
82
+ information about VCL (Varnish Configuration Language) which is the
83
+ heart of Varnish.
84
+ If you need professional service for setup your server please contact
85
+ Varnish Software for commercial support for the Varnish Cache software.
86
+ Check out their website or send them a mail at
87
+ sales@varnish-software.com.
88
+
89
+
90
+ 3. Installation
91
+ ===============
92
+
93
+ The installation of the Magento module is pretty easy:
94
+
95
+ 1. Copy the contents of the app directory in the archive to the app
96
+ directory of your Magento instance.
97
+ 2. Go to the Magento backend and open the Cache Management (System ->
98
+ Cache Management) and refresh the configuration and layout cache.
99
+
100
+ If any critical issue occurs you can’t easily solve go to
101
+ app/etc/modules, open "Phoenix_VarnishCache.xml" and set "false" in the
102
+ "active" tag to deactivate the PageCache module again. If necessary
103
+ clear Magento’s cache again.
104
+
105
+ As Varnish is already installed on your server you should just make a
106
+ backup of your default.vcl file which is shipped with Varnish. It should
107
+ be located at /etc/varnish/default.vcl. Copy the VCL file bundled with
108
+ the PageCache module for your version of Varnish (located at
109
+ app/code/local/Phoenix/VarnishCache/etc/default*.vcl) to your Varnish
110
+ configuration directory (/etc/varnish/).
111
+ Do not restart the Varnish service until you have checked the new VCL
112
+ file to adjust your hosting specific values (at least backends and purge
113
+ ACLs).
114
+
115
+ Proceed with the configuration.
116
+
117
+
118
+ 4. Configuration
119
+ ================
120
+
121
+ 4.1 PageCache module
122
+ ====================
123
+
124
+ In your Magento backend go to System -> Configuration -> System and open
125
+ the "PageCache powered by Varnish settings" tab.
126
+
127
+ In the following section the configuration options for the PageCache
128
+ powered by Varnish module are explained. Most of them can be changed on
129
+ website and store view level which allows fine granulated configurations
130
+ for different store frontends.
131
+ Note that if you change a value here Varnish will not reflect it until
132
+ you purge its HTML objects or the TTL of the cached objects expires.
133
+
134
+ Enable cache module
135
+ -------------------
136
+ This enables the basic functionality like setting HTTP headers and
137
+ allows cache cleaning on the Magento Cache Management page. This option
138
+ should be set to "Yes" globally even if you like to deactivate the
139
+ module for certain websites or store views. Otherwise the cleaning
140
+ options on the Cache Magement page won’t be available.
141
+
142
+ Varnish servers
143
+ ---------------
144
+ Add your Varnish server domains or IPs separated by semicolon.
145
+
146
+ Server port
147
+ -----------
148
+ The port your Varnish servers run on. This port is used for all servers
149
+ in your server list.
150
+
151
+ Disable caching
152
+ ---------------
153
+ This option allows you to deactivate caching of every Magento frontend
154
+ page in Varnish. This is useful for development or tests by passing all
155
+ requests through Varnish without caching them. If you have a staging
156
+ website within your Magento Enterprise instance make sure this option is
157
+ set to "Yes" for this website.
158
+
159
+ Disable caching for routes
160
+ --------------------------
161
+ Certain controllers or actions within Magento must not be cached by
162
+ Varnish as their response surely contains custom data or it is necessary
163
+ to process a request in database (API calls, payment callbacks).
164
+ Although Varnish passes all POST requests (which most often are used to
165
+ submit forms with custom information etc.) you can also define the
166
+ controllers and actions that should have the "no-cache" flag in their
167
+ HTTP response header.
168
+ Note: The function relies on
169
+ Mage_Core_Controller_Varien_Action::getFullActionName().
170
+
171
+ Disable caching vars
172
+ --------------------
173
+ Some GET variables in the frontend will not only change a single page
174
+ but will be stored in the visitor session and change the output of all
175
+ following request that might not have this GET parameter. For example a
176
+ store view, language or currency switch will only pass the parameter
177
+ once to Magento to change the output and all following requests will not
178
+ contain this parameter in the URL as the information is taken from the
179
+ visitor’s session.
180
+ As Varnish is not session aware it can handle only one content per
181
+ domain + URL combination. To prevent any conflicts with this behavior
182
+ the PageCache module will set a NO_CACHE cookie to the response to pass
183
+ all following request by this client through Varnish and let Magento
184
+ handle the request directly.
185
+
186
+ Default cache TTL
187
+ -----------------
188
+ Varnish delivers cached objects without requesting the web server or
189
+ Magento again for a certain period of time defined in the TTL (time to
190
+ live) value. You can adjust the TTL for your shop pages on store view
191
+ level which allows you to have different TTLs for your frontend pages.
192
+ Note that this field only allows numeric values in seconds. It doesn’t
193
+ support the same notation that can be used in the VCL. "2h" (2
194
+ hours) have to be entered as "7200" seconds.
195
+ For static contents Varnish uses the default TTL value defined in the
196
+ vcl_fetch section of the VCL (Default: set beresp.ttl = 4h).
197
+
198
+ Cache TTL for routes
199
+ ---------------------
200
+ This options allows to adjust Varnish cache TTL on per magento
201
+ controllers/actions basis. To add new TTL value for route 1)click
202
+ "Add route" button; 2)input route (e.g. "cms", "catalog_product_view");
203
+ 3)input TTL for route in seconds (e.g. "7200"). "Default Cache TTL"
204
+ value is used when no TTL for route defined.
205
+
206
+ Purge category
207
+ --------------
208
+ This option binds automatic purge of category (Varnish) cache with its
209
+ update event. If you always want up-to-date category information on
210
+ front-end set the option value to "Yes" and category cache will be
211
+ invalidated each time a category update occurs.
212
+
213
+ Purge product
214
+ --------------
215
+ This option binds purge of product (Varnish) cache with product and
216
+ product's stock update. If set to "Yes" product pages cache is
217
+ invalidated each time product update or product's stock update occurs.
218
+ Additionally, if "Purge Category" option is set to "Yes" this triggers
219
+ product's categories cache purge on product/product stock update.
220
+ This option is useful to keep product pages and categories up-to-date
221
+ when product becomes out of stock (e.g. when the last item purchased by
222
+ a customer).
223
+
224
+ Purge CMS page
225
+ --------------
226
+ This option binds automatic purge of CMS page (Varnish) cache with its
227
+ update event. If set to "Yes" CMS page cache is invalidated each time
228
+ CMS page update event occurs (e.g. CMS page content update via Magento
229
+ admin).
230
+
231
+ Debug
232
+ -----
233
+ The PageCache module adds several HTTP headers to let Varnish know what
234
+ to do with the Magento response. Also Varnish adds several tags in the
235
+ HTTP headers to pass information to the client to allow debugging of
236
+ requests directly in the browser. However this information should be
237
+ removed in production environments which can easily be done by setting
238
+ this value to "No".
239
+
240
+ Beside the HTTP headers the PageCache module can also log purge requests
241
+ to /var/log/varnish_cache.log if the developer log (System ->
242
+ Configuration -> Developer) is enabled. The log file will allow you to
243
+ see which PURGE requests have been sent to the Varnish servers.
244
+
245
+
246
+ 4.2 Varnish Cache (VCL)
247
+ =======================
248
+
249
+ PageCache powered by Varnish ships with a ready-to-go VCL file that let
250
+ Magento and Varnish play nicely together. Although the VCL should be
251
+ sufficient to start with Magento and Varnish right away you can of course
252
+ adjust it to your needs if necessary. Please see VCL documentation at
253
+ http://www.varnish-cache.org/docs/3.0/reference/vcl.html.
254
+
255
+ When putting Varnish in front of your web server (backend) you will have
256
+ to change the web server’s port which is normally port 80. We recommend
257
+ to change its’ listen port to 8080 which is already configured in the
258
+ VCL. If your Varnish server doesn’t run on the same server as your web
259
+ server (backend) you need to adjust the default backend at the beginning
260
+ of the VCL file. Also you will have to adjust the purge ACL below to
261
+ allow the purge requests which are triggered from the Magento backend
262
+ which have the IP of your web server (backend).
263
+
264
+ We also recommend adjusting the vcl_error section which will be echoed
265
+ if the backend (Magento) is not available.
266
+
267
+ As special feature Varnish’s saint mode has been enabled in the
268
+ vcl_fetch section by default, which allows Varnish to deliver content
269
+ even if an object is expired when your backend is unreachable to refresh
270
+ it. With this feature your uptime and availability will be increased for
271
+ better customer experience.
272
+
273
+ Beside the VCL don't forget to check Varnish's startup parameters. They
274
+ allow fine tuning of timeouts, cache size, location of the VCL file and
275
+ much more. Checkout Varnish Cache documentation for details.
276
+
277
+
278
+ 5. Cache cleaning, PURGE requests
279
+ =================================
280
+
281
+ Varnish caches objects for a certain period of time according to their
282
+ TTL. After that the object will not be requested from the web server or
283
+ Magento again. Until the TTL expires Varnish will deliver the cached
284
+ object no matter what will change within Magento or the webserver’s file
285
+ system. To force Varnish to cleanup its’ cache and to retrieve the
286
+ information again from the backend you can trigger a purge/ban requests
287
+ right from Magento.
288
+
289
+ In the Magento backend go to System -> Cache Management. If you have
290
+ enabled the PageCache module in the configuration you will see a new
291
+ button "Clean Varnish Cache" in the "Additional Cache Management"
292
+ section. You can purge all objects in Varnish Cache by just clicking
293
+ "Clean Varnish Cache" or define which store view and/or content type
294
+ should be purged. For the store views PageCache will look up the
295
+ configured domains in System -> Configuration -> Web and pass the
296
+ domain(s) of the selected store view as an argument of the purge request
297
+ to Varnish. This will allow you for example to remove the CSS files of a
298
+ certain store view in Varnish if they have been modified without the
299
+ need to invalidate any other object which will save a lot of resources
300
+ on high frequented stores.
301
+
302
+ Beside these direct purge requests PageCache has observers for "Flush
303
+ Magento Cache" and "Flush Cache Storage" to purge all objects in Varnish
304
+ together with the Magento cache refresh. It also has observers for
305
+ "Flush Catalog Images Cache" and "Flush JavaScript/CSS Cache" to clean
306
+ objects that match the appropriate URL path in Varnish. All HTML objects
307
+ will be purged too as the product image and JavaScript/CSS paths will
308
+ change when Magento generated them again so the cached HTML objects
309
+ might contain wrong paths if not refreshed.
310
+ Introduced in PageCache 1.2.0 you can also enable automatic purging of CMS
311
+ pages, categories and products when they are saved (see configuration).
312
+ If you don’t want these observers to take automatic action comment them
313
+ out in the config.xml of the PageCache module.
314
+
315
+
316
+ 6. Troubleshooting
317
+ ==================
318
+
319
+ 6.1 Known issues
320
+ ================
321
+
322
+ - "Recently Viewed Products" box is not supported (requires ESI support;
323
+ Q1/12)
324
+ - Logging and statistics will be fragmentary (Varnish won't pass cached
325
+ requests to the webserver or Magento). Instead make use of a JavaScript
326
+ based statistics like Google Analytics or contact Varnish Software who
327
+ offers additional tools for that as part of their subscription services.
328
+
329
+
330
+ 6.2 Prevent caching for custom modules
331
+ ======================================
332
+
333
+ In your Magento installation you will surely have custom modules whose
334
+ HTML output shouldn’t be cached. Therefore you have two options: Either
335
+ add their controllers to the "Disable caching for routes" configuration
336
+ to prevent caching of their output. Or, if your module changes the
337
+ visitor session for all following request, dispatch an event in your
338
+ Magento module and add an observer to let PageCache set a NO_CACHE
339
+ cookie (compare config.xml):
340
+
341
+ <catalog_product_compare_add_product>
342
+ <observers>
343
+ <varnishcache>
344
+ <class>varnishcache/observer</class>
345
+ <method>disablePageCachingPermanent</method>
346
+ </varnishcache>
347
+ </observers>
348
+ </catalog_product_compare_add_product>
349
+
350
+
351
+ 6.3 Prevent caching for HTML/PHP files outsite Magento
352
+ ======================================================
353
+
354
+ Varnish as a proxy respects caching information from the backend server like
355
+ "Cache-Control: max-age=600" or "Expires: Thu, 19 Nov 2021 08:52:00 GMT".
356
+ PageCache powered by Varnish uses "Expires" to tell Varnish whether a Magento
357
+ page is cacheable and how long.
358
+ If you have mod_expires installed in your Apache and the Magento default setting
359
+ in your .htaccess 'ExpiresDefault "access plus 1 year"' this will allow Varnish
360
+ to cache every object outside of Magento (e.g. files in js, media or skin
361
+ folder) for one year.
362
+ However this also affects HTML or PHP files if they don't set their own
363
+ "Cache-Control" or "Expires" header. If you don't want HTML contents which don't
364
+ explicitly allow caching to be cached by Varnish, add this line to the
365
+ mod_expires section of your htaccess file:
366
+
367
+ ExpiresByType text/html A0
368
+
369
+ This will set the expiry time of the object equal to the delivery time which
370
+ will not allow Varnish to cache the object.
371
+
372
+ Note that if a "Expires" header is already set in the HTTP response header
373
+ mod_expires will respect it and pass this header without changes.
374
+
375
+
376
+ 6.4 Debugging requests
377
+ ======================
378
+
379
+ If Varnish does not behave like you expect there are some great tools
380
+ that will help you to analyze what’s going on. First you should activate
381
+ the debug mode in the PageCache module and purge the HTML objects in
382
+ System -> Cache Management to pass the full HTTP headers to your
383
+ browser.
384
+
385
+ A really great help for debugging requests is the "varnishlog" command
386
+ that is part of the Varnish distribution. You can call it on the shell
387
+ to show only HTML requests:
388
+
389
+ varnishlog -c -o TxHeader "Content-Type: text/html"
390
+
391
+
392
+ You can also filter the output for a certain client IP:
393
+
394
+ varnishlog -c -o ReqStart 123.456.78.9
395
+
396
+
397
+ If you still can’t solve the issues please contact
398
+ support@phoenix-media.eu to request professional services.
399
+
400
+
401
+ 7. Changelog
402
+ ============
403
+
404
+ 1.2.0
405
+ - Changed license to OSL for Community Edition
406
+ - Instantly purge cache items of CMS pages, categories and products on save
407
+ - Configure different TTLs per route/controller
408
+ - Use "Cache-Control:s-maxage=x" instead of propriatary headers to control Varnish
409
+ - Improved Magento EE compatibility
410
+ - Allow frontend Varnish caching while beeing logged in the backend
411
+ - Added design exceptions (beta)
412
+
413
+ 1.1.0
414
+ - Full support for Varnish 3.0
415
+ - Replaced no-cache and X-Cache-Ttl header with standard "Expires" header
416
+ - Removed C-code in VCLs and splitted default.vcl for 2.1 and 3.0
417
+ - Improved hit rate and compatibility for different environments
418
+
419
+ 1.0.0
420
+ - Initial release
app/code/community/Phoenix/VarnishCache/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Block/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Block/Adminhtml/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Block/Adminhtml/Cache/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Block/Adminhtml/Cache/Additional.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Magento Enterprise Edition License
8
+ * that is bundled with this package in the file LICENSE_VARNISH_CACHE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.phoenix-media.eu/license/license_varnish_cache.txt
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://www.phoenix-media.eu/license/license_varnish_cache.txt
19
+ */
20
+
21
+ /**
22
+ * System cache management additional block
23
+ *
24
+ * @category Phoenix
25
+ * @package Phoenix_VarnishCache
26
+ */
27
+ class Phoenix_VarnishCache_Block_Adminhtml_Cache_Additional extends Mage_Adminhtml_Block_Template
28
+ {
29
+ /**
30
+ * Get clean cache url
31
+ *
32
+ * @return string
33
+ */
34
+ public function getCleanVarnishCacheUrl()
35
+ {
36
+ return $this->getUrl('*/varnishCache/clean');
37
+ }
38
+
39
+ /**
40
+ * Check if block can be displayed
41
+ *
42
+ * @return bool
43
+ */
44
+ public function canShowButton()
45
+ {
46
+ return Mage::helper('varnishcache')->isEnabled();
47
+ }
48
+
49
+ /**
50
+ * Get store selection
51
+ *
52
+ * @return string
53
+ */
54
+ public function getStoreOptions()
55
+ {
56
+ $options = array(array('value' => '', 'label' => Mage::helper('varnishcache')->__('All stores')));
57
+
58
+ $stores = Mage::getModel('adminhtml/system_config_source_store')->toOptionArray();
59
+
60
+ return array_merge($options, $stores);
61
+ }
62
+
63
+ /**
64
+ * Get content types
65
+ */
66
+ public function getContentTypeOptions()
67
+ {
68
+ $options = array(array('value' => '', 'label' => Mage::helper('varnishcache')->__('All content types')));
69
+ foreach (Mage::getModel('varnishcache/control')->getContentTypes() as $value => $label) {
70
+ $options[] = array('value' => $value, 'label' => $label);
71
+ }
72
+ return $options;
73
+ }
74
+ }
app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/Config/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/Config/Fieldset/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/Config/Fieldset/RouteTTL.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Block_Adminhtml_System_Config_Fieldset_RouteTTL
22
+ extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
23
+ {
24
+ public function __construct()
25
+ {
26
+ $this->addColumn(
27
+ 'regexp', array(
28
+ 'label' => Mage::helper('adminhtml')->__('Route'),
29
+ 'style' => 'width:120px')
30
+ );
31
+ $this->addColumn(
32
+ 'value', array(
33
+ 'label' => Mage::helper('adminhtml')->__('TTL'),
34
+ 'style' => 'width:120px')
35
+ );
36
+ $this->_addAfter = false;
37
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add route');
38
+ parent::__construct();
39
+ }
40
+
41
+ protected function _toHtml()
42
+ {
43
+ return '<div id="system_varnishcache_routes_ttl">' . parent::_toHtml() . '</div>';
44
+ }
45
+ }
app/code/community/Phoenix/VarnishCache/Block/Adminhtml/System/Config/Fieldset/Versioninfo.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Block_Adminhtml_System_Config_Fieldset_Versioninfo
22
+ extends Mage_Adminhtml_Block_Abstract
23
+ implements Varien_Data_Form_Element_Renderer_Interface
24
+ {
25
+ /**
26
+ * Render fieldset html
27
+ *
28
+ * @param Varien_Data_Form_Element_Abstract $element
29
+ * @return string
30
+ */
31
+ public function render(Varien_Data_Form_Element_Abstract $element)
32
+ {
33
+ $info = '<fieldset class="config">
34
+ '.Mage::helper('varnishcache')->__('PageCache powered by Varnish version: %s', Mage::getConfig()->getNode('modules/Phoenix_VarnishCache/version')).'
35
+ </fieldset>';
36
+
37
+ return $info;
38
+ }
39
+ }
app/code/community/Phoenix/VarnishCache/Helper/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Helper/Cache.php ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Helper_Cache extends Mage_Core_Helper_Abstract
22
+ {
23
+ const XML_PATH_VARNISH_CACHE_DISABLE_CACHING = 'system/varnishcache/disable_caching';
24
+ const XML_PATH_VARNISH_CACHE_DISABLE_CACHING_VARS = 'system/varnishcache/disable_caching_vars';
25
+ const XML_PATH_VARNISH_CACHE_DISABLE_ROUTES = 'system/varnishcache/disable_routes';
26
+ const XML_PATH_VARNISH_CACHE_TTL = 'system/varnishcache/ttl';
27
+ const XML_PATH_VARNISH_CACHE_ROUTES_TTL = 'system/varnishcache/routes_ttl';
28
+
29
+ /**
30
+ * Cookie name for disabling external caching
31
+ *
32
+ * @var string
33
+ */
34
+ const NO_CACHE_COOKIE = 'EXTERNAL_NO_CACHE';
35
+
36
+ /**
37
+ * Header for debug flag
38
+ *
39
+ * @var string
40
+ * @return void
41
+ */
42
+ const DEBUG_HEADER = 'X-Cache-Debug: 1';
43
+
44
+
45
+ /**
46
+ * Get Cookie object
47
+ *
48
+ * @return Mage_Core_Model_Cookie
49
+ */
50
+ public static function getCookie()
51
+ {
52
+ return Mage::getSingleton('core/cookie');
53
+ }
54
+
55
+
56
+ /**
57
+ * Set appropriate cache control headers
58
+ *
59
+ * @return Phoenix_VarnishCache_Helper_Cache
60
+ */
61
+ public function setCacheControlHeaders()
62
+ {
63
+ $request = Mage::app()->getRequest();
64
+
65
+ // set debug header
66
+ if (Mage::helper('varnishcache')->isDebug()) {
67
+ $this->setDebugHeader();
68
+ }
69
+
70
+ // check for disable caching vars
71
+ if ($disableCachingVars = trim(Mage::getStoreConfig(self::XML_PATH_VARNISH_CACHE_DISABLE_CACHING_VARS))) {
72
+ foreach (explode(',', $disableCachingVars) as $param) {
73
+ if ($request->getParam(trim($param))) {
74
+ $this->setNoCacheHeader();
75
+ return $this->setNoCacheCookie();
76
+ }
77
+ }
78
+ }
79
+
80
+ // renew no-cache cookie
81
+ $this->setNoCacheCookie(true);
82
+
83
+ // disable page caching for POSTs and no_cache parameters
84
+ if ($request->isPost() || $request->getParam('no_cache') ||
85
+ !in_array(Mage::app()->getResponse()->getHttpResponseCode(), array(200, 301, 404))) {
86
+ return $this->setNoCacheHeader();
87
+ }
88
+
89
+ // disable page caching because of configuration
90
+ if (Mage::getStoreConfigFlag(self::XML_PATH_VARNISH_CACHE_DISABLE_CACHING)) {
91
+ return $this->setNoCacheHeader();
92
+ }
93
+
94
+
95
+ /**
96
+ * Check for ruleset depending on request path
97
+ *
98
+ * see: Mage_Core_Controller_Varien_Action::getFullActionName()
99
+ */
100
+ $fullActionName = $request->getRequestedRouteName().'_'.
101
+ $request->getRequestedControllerName().'_'.
102
+ $request->getRequestedActionName();
103
+
104
+ // check caching blacklist for request routes
105
+ $disableRoutes = explode("\n", trim(Mage::getStoreConfig(self::XML_PATH_VARNISH_CACHE_DISABLE_ROUTES)));
106
+ foreach ($disableRoutes as $route) {
107
+ $route = trim($route);
108
+ // if route is found at first position we have a hit
109
+ if (!empty($route) && strpos($fullActionName, $route) === 0) {
110
+ return $this->setNoCacheHeader();
111
+ }
112
+ }
113
+
114
+ // set TTL header
115
+ $regexp = null;
116
+ $value = null;
117
+ $routesTtl = unserialize(Mage::getStoreConfig(self::XML_PATH_VARNISH_CACHE_ROUTES_TTL));
118
+ if (is_array($routesTtl)) {
119
+ foreach ($routesTtl as $routeTtl) {
120
+ extract($routeTtl, EXTR_OVERWRITE);
121
+ $regexp = trim($regexp);
122
+ if (!empty($regexp) && strpos($fullActionName, $regexp) === 0) {
123
+ break;
124
+ }
125
+ $value = null;
126
+ }
127
+ }
128
+ if (!isset($value)) {
129
+ $value = Mage::getStoreConfig(self::XML_PATH_VARNISH_CACHE_TTL);
130
+ }
131
+ $this->setTtlHeader(intval($value));
132
+
133
+ return $this;
134
+ }
135
+
136
+ /**
137
+ * Check for a NO_CACHE cookie and if found force a TTL=0 for this
138
+ * page.
139
+ *
140
+ * @return void
141
+ */
142
+ public static function sanitizeCacheControlHeader()
143
+ {
144
+ $cookie = self::getCookie();
145
+ if ($cookie->get(self::NO_CACHE_COOKIE)) {
146
+ self::setNoCacheHeader();
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Disable caching of this and all future request for this visitor
152
+ *
153
+ * @return Phoenix_VarnishCache_Helper_Cache
154
+ */
155
+ public function setNoCacheCookie($renewOnly = false)
156
+ {
157
+ if ($this->getCookie()->get(self::NO_CACHE_COOKIE)) {
158
+ $this->getCookie()->renew(self::NO_CACHE_COOKIE);
159
+ } elseif (!$renewOnly) {
160
+ $this->getCookie()->set(self::NO_CACHE_COOKIE, 1);
161
+ }
162
+ return $this;
163
+ }
164
+
165
+ /**
166
+ * Disable caching for this request
167
+ *
168
+ * @return Phoenix_VarnishCache_Helper_Cache
169
+ */
170
+ public static function setNoCacheHeader()
171
+ {
172
+ return self::setTtlHeader(0);
173
+ }
174
+
175
+ /**
176
+ * Set debug flag in HTTP header
177
+ *
178
+ * @return Phoenix_VarnishCache_Helper_Cache
179
+ */
180
+ public function setDebugHeader()
181
+ {
182
+ $el = explode(':', self::DEBUG_HEADER, 2);
183
+ Mage::app()->getResponse()->setHeader($el[0], $el[1], true);
184
+ return $this;
185
+ }
186
+
187
+ /**
188
+ * Set TTL HTTP header for cache
189
+ *
190
+ * For mod_expires it is important to have "Expires" header. However for
191
+ * Varnish it is easier to deal with "Cache-Control: s-maxage=xx" as it
192
+ * is relative to its system time and not depending on timezone settings.
193
+ *
194
+ * Magento normaly doesn't set any Cache-Control or Expires headers. If they
195
+ * appear the are set by PHP's setcookie() function.
196
+ *
197
+ * @param int Time to life in seconds. Value greater than 0 means "cacheable".
198
+ * @return void
199
+ */
200
+ public static function setTtlHeader($ttl)
201
+ {
202
+ $maxAge = 's-maxage=' . (($ttl < 0) ? 0 : $ttl);
203
+ $cacheControlValue = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, '.$maxAge;
204
+
205
+ // retrieve existing "Cache-Control" header
206
+ $response = Mage::app()->getResponse();
207
+ $headers = $response->getHeaders();
208
+
209
+ foreach ($headers as $key => $header) {
210
+ if ('Cache-Control' == $header['name'] && !empty($header['value'])) {
211
+ // replace existing "max-age" value
212
+ if (strpos($header['value'], 'age=') !== false) {
213
+ $cacheControlValue = preg_replace('/(s-)?max[-]?age=[0-9]+/', $maxAge, $header['value']);
214
+ } else {
215
+ $cacheControlValue .= $header['value'].', '.$maxAge;
216
+ }
217
+ }
218
+ }
219
+
220
+ // set "Cache-Control" header with "s-maxage" value
221
+ $response->setHeader('Cache-Control', $cacheControlValue, true);
222
+
223
+ // set "Expires" header in the past to keep mod_expires from applying it's ruleset
224
+ $response->setHeader('Expires', 'Mon, 31 Mar 2008 10:00:00 GMT', true);
225
+
226
+ // set "Pragma: no-cache" - just in case
227
+ $response->setHeader('Pragma', 'no-cache', true);
228
+ }
229
+
230
+ /**
231
+ * Find all domains for store
232
+ *
233
+ * @return string
234
+ */
235
+ public function getStoreDomainList($storeId = 0, $seperator = '|')
236
+ {
237
+ $storeIds = array($storeId);
238
+
239
+ // if $store is empty or 0 get all store ids
240
+ if (empty($storeId)) {
241
+ $storeIds = Mage::getResourceModel('core/store_collection')->getAllIds();
242
+ }
243
+
244
+ $domains = array();
245
+ $urlTypes = array(
246
+ Mage_Core_Model_Store::URL_TYPE_LINK,
247
+ Mage_Core_Model_Store::URL_TYPE_DIRECT_LINK,
248
+ Mage_Core_Model_Store::URL_TYPE_WEB,
249
+ Mage_Core_Model_Store::URL_TYPE_SKIN,
250
+ Mage_Core_Model_Store::URL_TYPE_JS,
251
+ Mage_Core_Model_Store::URL_TYPE_MEDIA
252
+ );
253
+ foreach ($storeIds as $storeId) {
254
+ $store = Mage::getModel('core/store')->load($storeId);
255
+
256
+ foreach ($urlTypes as $urlType) {
257
+ // get non-secure store domain
258
+ $domains[] = Zend_Uri::factory($store->getBaseUrl($urlType, false))->getHost();
259
+ // get secure store domain
260
+ $domains[] = Zend_Uri::factory($store->getBaseUrl($urlType, true))->getHost();
261
+ }
262
+ }
263
+
264
+ // get only unique values
265
+ $domains = array_unique($domains);
266
+
267
+ return implode($seperator, $domains);
268
+ }
269
+ }
270
+
app/code/community/Phoenix/VarnishCache/Helper/Control/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Helper/Control/Catalog/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Helper/Control/Catalog/Category.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Helper_Control_Catalog_Category extends Phoenix_VarnishCache_Helper_Data
22
+ {
23
+ const XML_PATH_VARNISH_CACHE_PURGE = 'system/varnishcache/purge_catalog_category';
24
+
25
+ /**
26
+ * Returns true if Varnish cache is enabled and category should be purged on save
27
+ *
28
+ * @return boolean
29
+ */
30
+ public function canPurge()
31
+ {
32
+ return $this->isEnabled() && $this->isPurge();
33
+ }
34
+
35
+ /**
36
+ * Returns true if category should be purged on save
37
+ *
38
+ * @return boolean
39
+ */
40
+ public function isPurge()
41
+ {
42
+ return Mage::getStoreConfigFlag(self::XML_PATH_VARNISH_CACHE_PURGE);
43
+ }
44
+ }
45
+
app/code/community/Phoenix/VarnishCache/Helper/Control/Catalog/Product.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Helper_Control_Catalog_Product extends Phoenix_VarnishCache_Helper_Data
22
+ {
23
+ const XML_PATH_VARNISH_CACHE_PURGE = 'system/varnishcache/purge_catalog_product';
24
+
25
+ /**
26
+ * Returns true if Varnish cache is enabled and product should be purged on save
27
+ *
28
+ * @return boolean
29
+ */
30
+ public function canPurge()
31
+ {
32
+ return $this->isEnabled() && $this->isPurge();
33
+ }
34
+
35
+ /**
36
+ * Returns true if CMS page should be purged on save
37
+ *
38
+ * @return boolean
39
+ */
40
+ public function isPurge()
41
+ {
42
+ return Mage::getStoreConfigFlag(self::XML_PATH_VARNISH_CACHE_PURGE);
43
+ }
44
+ }
45
+
app/code/community/Phoenix/VarnishCache/Helper/Control/Cms/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Helper/Control/Cms/Page.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Helper_Control_Cms_Page extends Phoenix_VarnishCache_Helper_Data
22
+ {
23
+ const XML_PATH_VARNISH_CACHE_PURGE = 'system/varnishcache/purge_cms_page';
24
+
25
+ /**
26
+ * Returns true if Varnish cache is enabled and category should be purged on save
27
+ *
28
+ * @return boolean
29
+ */
30
+ public function canPurge()
31
+ {
32
+ return $this->isEnabled() && $this->isPurge();
33
+ }
34
+
35
+ /**
36
+ * Returns true if category should be purged on save
37
+ *
38
+ * @return boolean
39
+ */
40
+ public function isPurge()
41
+ {
42
+ return Mage::getStoreConfigFlag(self::XML_PATH_VARNISH_CACHE_PURGE);
43
+ }
44
+ }
45
+
app/code/community/Phoenix/VarnishCache/Helper/Data.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Helper_Data extends Mage_Core_Helper_Abstract
22
+ {
23
+ const XML_PATH_VARNISH_CACHE_ENABLED = 'system/varnishcache/enabled';
24
+ const XML_PATH_VARNISH_CACHE_DEBUG = 'system/varnishcache/debug';
25
+
26
+ /**
27
+ * Check whether Varnish cache is enabled
28
+ *
29
+ * @return bool
30
+ */
31
+ public function isEnabled()
32
+ {
33
+ return Mage::getStoreConfigFlag(self::XML_PATH_VARNISH_CACHE_ENABLED);
34
+ }
35
+
36
+ /**
37
+ * Check whether debuging is enabled
38
+ *
39
+ * @return bool
40
+ */
41
+ public function isDebug()
42
+ {
43
+ if (Mage::getStoreConfigFlag(self::XML_PATH_VARNISH_CACHE_DEBUG)) {
44
+ return true;
45
+ }
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ * Log debugging data
51
+ *
52
+ * @param string|array
53
+ * @return void
54
+ */
55
+ public function debug($debugData)
56
+ {
57
+ if ($this->isDebug()) {
58
+ Mage::log($debugData, null, 'varnish_cache.log');
59
+ }
60
+ }
61
+
62
+ /**
63
+ * @return string
64
+ */
65
+ public function getLicenseFilePath()
66
+ {
67
+ return Mage::getBaseDir() . DS . 'LICENSE_VARNISH_CACHE.lic';
68
+ }
69
+
70
+ /**
71
+ * @return string
72
+ */
73
+ public function getLicenseCheckUrl()
74
+ {
75
+ return Mage::getModel('adminhtml/url')->getUrl('*/varnishCache/checkLicense');
76
+ }
77
+
78
+ /**
79
+ * Get Varnish control model
80
+ *
81
+ * @return Phoenix_VarnishCache_Model_Control
82
+ */
83
+ public function getCacheControl()
84
+ {
85
+ return Mage::getSingleton('varnishcache/control');
86
+ }
87
+ }
app/code/community/Phoenix/VarnishCache/Model/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Catalog/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Catalog/Category/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Catalog/Category/Product.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Catalog_Category_Product extends Mage_Core_Model_Abstract
22
+ {
23
+ protected function _construct()
24
+ {
25
+ $this->_init('varnishcache/catalog_category_product');
26
+ }
27
+ }
app/code/community/Phoenix/VarnishCache/Model/Catalog/Product/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Catalog/Product/Relation.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Catalog_Product_Relation extends Mage_Core_Model_Abstract
22
+ {
23
+ protected function _construct()
24
+ {
25
+ $this->_init('catalog/product_relation');
26
+ }
27
+ }
app/code/community/Phoenix/VarnishCache/Model/Cms/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Cms/Page/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Cms/Page/Store.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Cms_Page_Store extends Mage_Core_Model_Abstract
22
+ {
23
+ protected function _construct()
24
+ {
25
+ $this->_init('varnishcache/cms_page_store');
26
+ }
27
+ }
app/code/community/Phoenix/VarnishCache/Model/Control.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Varnish cache control model
23
+ *
24
+ * @category Phoenix
25
+ * @package Phoenix_VarnishCache
26
+ */
27
+ class Phoenix_VarnishCache_Model_Control
28
+ {
29
+ const XML_PATH_VARNISH_SERVERS = 'system/varnishcache/servers';
30
+ const XML_PATH_VARNISH_PORT = 'system/varnishcache/port';
31
+
32
+ const CONTENT_TYPE_HTML = 'text/html';
33
+ const CONTENT_TYPE_CSS = 'text/css';
34
+ const CONTENT_TYPE_JS = 'javascript';
35
+ const CONTENT_TYPE_IMAGE = 'image/';
36
+
37
+ const VARNISH_HEADER_REGEX = 'X-Purge-Regex';
38
+ const VARNISH_HEADER_HOST = 'X-Purge-Host';
39
+ const VARNISH_HEADER_CONTENT_TYPE = 'X-Purge-Content-Type';
40
+
41
+
42
+ /**
43
+ * Get content types as option array
44
+ */
45
+ public function getContentTypes()
46
+ {
47
+ $contentTypes = array(
48
+ self::CONTENT_TYPE_HTML => Mage::helper('varnishcache')->__('HTML'),
49
+ self::CONTENT_TYPE_CSS => Mage::helper('varnishcache')->__('CSS'),
50
+ self::CONTENT_TYPE_JS => Mage::helper('varnishcache')->__('JavaScript'),
51
+ self::CONTENT_TYPE_IMAGE => Mage::helper('varnishcache')->__('Images')
52
+ );
53
+
54
+ return $contentTypes;
55
+ }
56
+
57
+
58
+ /**
59
+ * Clean Varnish cache
60
+ *
61
+ * @param string domain names for cleaning
62
+ * @param string RegEx pattern for url matching
63
+ * @param string content type to clean
64
+ * @return void
65
+ */
66
+ public function clean($domains, $urlRegEx = '.*', $contentType = '.*')
67
+ {
68
+ try {
69
+ $headers = array(
70
+ self::VARNISH_HEADER_HOST => '^('.str_replace('.', '.', $domains).')$',
71
+ self::VARNISH_HEADER_REGEX => (empty($urlRegEx) ? '.*' : $urlRegEx),
72
+ self::VARNISH_HEADER_CONTENT_TYPE => (empty($contentType) ? '.*' : $contentType)
73
+ );
74
+
75
+ $this->_purgeCacheServers($headers);
76
+
77
+ Mage::helper('varnishcache')->debug('Purged Varnish items with parameters '.var_export($headers, true));
78
+ } catch (Exception $e) {
79
+ Mage::helper('varnishcache')->debug('Error during purging: '.$e->getMessage());
80
+ return false;
81
+ }
82
+
83
+ return true;
84
+ }
85
+
86
+
87
+ /**
88
+ * Process all servers
89
+ */
90
+ protected function _purgeCacheServers(Array $headers)
91
+ {
92
+ $servers = $this->_getVarnishServers();
93
+ if (empty($servers)) {
94
+ return;
95
+ }
96
+
97
+ // process all servers
98
+ foreach ($servers as $server) {
99
+ // compile url string with scheme, domain/server and port
100
+ $uri = 'http://'.$server;
101
+ if ($port = trim(Mage::getStoreConfig(self::XML_PATH_VARNISH_PORT))) {
102
+ $uri .= ':'.$port;
103
+ }
104
+ $uri .= '/';
105
+
106
+ try {
107
+ // create HTTP client
108
+ $client = new Zend_Http_Client();
109
+ $client->setUri($uri)
110
+ ->setHeaders($headers)
111
+ ->setConfig(array('timeout'=>15));
112
+
113
+ // send PURGE request
114
+ $response = $client->request('PURGE');
115
+
116
+ // check response
117
+ if ($response->getStatus() != '200') {
118
+ throw new Exception('Return status '.$response->getStatus());
119
+ }
120
+ } catch (Exception $e) {
121
+ Mage::helper('varnishcache')->debug('Purging on server '.$server.' failed ('.$e->getMessage().').');
122
+ }
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Get Varnish servers for purge
128
+ *
129
+ * @return string
130
+ */
131
+ protected function _getVarnishServers()
132
+ {
133
+ return explode(';', Mage::getStoreConfig(self::XML_PATH_VARNISH_SERVERS));
134
+ }
135
+ }
app/code/community/Phoenix/VarnishCache/Model/Control/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Control/Abstract.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Control_Abstract
22
+ {
23
+ protected $_helperName;
24
+
25
+ /**
26
+ * Retrieve adminhtml session model object
27
+ *
28
+ * @return Mage_Adminhtml_Model_Session
29
+ */
30
+ protected function _getSession()
31
+ {
32
+ return Mage::getSingleton('adminhtml/session');
33
+ }
34
+
35
+ /**
36
+ * Returns true if Varnish PageCache enabled and Purge Product config option set to 1
37
+ *
38
+ * @return bool
39
+ */
40
+ protected function _canPurge()
41
+ {
42
+ if (!$this->_helperName) {
43
+ return false;
44
+ }
45
+ return Mage::helper($this->_helperName)->canPurge();
46
+ }
47
+
48
+ /**
49
+ * Get Varnish control model
50
+ *
51
+ * @return Phoenix_VarnishCache_Model_Control
52
+ */
53
+ protected function _getCacheControl()
54
+ {
55
+ return Mage::helper('varnishcache')->getCacheControl();
56
+ }
57
+
58
+ /**
59
+ * Returns domain list for store
60
+ *
61
+ * @return array
62
+ */
63
+ protected function _getStoreDomainList()
64
+ {
65
+ return Mage::helper('varnishcache/cache')->getStoreDomainList();
66
+ }
67
+
68
+ /**
69
+ * Get url rewrite collection
70
+ *
71
+ * @return Phoenix_VarnishCache_Model_Resource_Mysql4_Core_Url_Rewrite_Collection
72
+ */
73
+ protected function _getUrlRewriteCollection()
74
+ {
75
+ return Mage::getResourceModel('varnishcache/core_url_rewrite_collection');
76
+ }
77
+
78
+ /**
79
+ * Get product relation collection
80
+ *
81
+ * @return Phoenix_VarnishCache_Model_Resource_Mysql4_Catalog_Product_Relation_Collection
82
+ */
83
+ protected function _getProductRelationCollection()
84
+ {
85
+ return Mage::getResourceModel('varnishcache/catalog_product_relation_collection');
86
+ }
87
+
88
+ /**
89
+ * Get catalog category product relation collection
90
+ *
91
+ * @return Phoenix_VarnishCache_Model_Resource_Mysql4_Catalog_Product_Relation_Collection
92
+ */
93
+ protected function _getCategoryProductRelationCollection()
94
+ {
95
+ return Mage::getResourceModel('varnishcache/catalog_category_product_collection');
96
+ }
97
+ }
app/code/community/Phoenix/VarnishCache/Model/Control/Catalog/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Control/Catalog/Category.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Control_Catalog_Category
22
+ extends Phoenix_VarnishCache_Model_Control_Abstract
23
+ {
24
+ protected $_helperName = 'varnishcache/control_catalog_category';
25
+
26
+ /**
27
+ * Purge Category
28
+ *
29
+ * @param Mage_Catalog_Model_Category $category
30
+ * @return Phoenix_VarnishCache_Model_Control_Catalog_Category
31
+ */
32
+ public function purge(Mage_Catalog_Model_Category $category)
33
+ {
34
+ if ($this->_canPurge()) {
35
+ $this->_purgeById($category->getId());
36
+ if ($categoryName = $category->getName()) {
37
+ $this->_getSession()->addSuccess(
38
+ Mage::helper('varnishcache')->__('Varnish cache for "%s" has been purged.', $categoryName)
39
+ );
40
+ }
41
+ }
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * Purge Category by id
47
+ *
48
+ * @param int $id
49
+ * @return Phoenix_VarnishCache_Model_Control_Catalog_Category
50
+ */
51
+ public function purgeById($id)
52
+ {
53
+ if ($this->_canPurge()) {
54
+ $this->_purgeById($id);
55
+ }
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Purge Category by id
61
+ *
62
+ * @param int $id
63
+ * @return Phoenix_VarnishCache_Model_Control_Catalog_Category
64
+ */
65
+ protected function _purgeById($id)
66
+ {
67
+ $collection = $this->_getUrlRewriteCollection()
68
+ ->filterAllByCategoryId($id);
69
+ foreach ($collection as $urlRewriteRule) {
70
+ $urlRegexp = '/' . $urlRewriteRule->getRequestPath();
71
+ $this->_getCacheControl()
72
+ ->clean($this->_getStoreDomainList(), $urlRegexp);
73
+ }
74
+ return $this;
75
+ }
76
+ }
app/code/community/Phoenix/VarnishCache/Model/Control/Catalog/Product.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Control_Catalog_Product
22
+ extends Phoenix_VarnishCache_Model_Control_Abstract
23
+ {
24
+ protected $_helperName = 'varnishcache/control_catalog_product';
25
+
26
+ /**
27
+ * Purge product
28
+ *
29
+ * @param Mage_Catalog_Model_Product $product
30
+ * @param bool $purgeParentProducts
31
+ * @param bool $purgeCategories
32
+ * @return Phoenix_VarnishCache_Model_Control_Catalog_Product
33
+ */
34
+ public function purge(Mage_Catalog_Model_Product $product, $purgeParentProducts = false, $purgeCategories = false)
35
+ {
36
+ if ($this->_canPurge()) {
37
+ $this->_purgeById($product->getId());
38
+ $this->_getSession()->addSuccess(
39
+ Mage::helper('varnishcache')->__('Varnish cache for "%s" has been purged.', $product->getName())
40
+ );
41
+ if ($purgeParentProducts) {
42
+ // purge parent products
43
+ $productRelationCollection = $this->_getProductRelationCollection()
44
+ ->filterByChildId($product->getId());
45
+ foreach ($productRelationCollection as $productRelation) {
46
+ $this->_purgeById($productRelation->getParentId());
47
+ }
48
+ // purge categories of parent products
49
+ if ($purgeCategories) {
50
+ $categoryProductCollection = $this->_getCategoryProductRelationCollection()
51
+ ->filterAllByProductIds($productRelationCollection->getAllIds());
52
+ $catalogCacheControl = $this->_getCategoryCacheControl();
53
+ foreach ($categoryProductCollection as $categoryProduct) {
54
+ $catalogCacheControl->purgeById($categoryProduct->getCategoryId());
55
+ }
56
+ }
57
+ }
58
+ if ($purgeCategories) {
59
+ $catalogCacheControl = $this->_getCategoryCacheControl();
60
+ foreach ($product->getCategoryCollection() as $category) {
61
+ $catalogCacheControl->purge($category);
62
+ }
63
+ $this->_getSession()->addSuccess(
64
+ Mage::helper('varnishcache')->__('Varnish cache for the product\'s categories has been purged.')
65
+ );
66
+ }
67
+ }
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * Purge product by id
73
+ *
74
+ * @param int $id
75
+ * @param bool $purgeParentProducts
76
+ * @param bool $purgeCategories
77
+ * @return Phoenix_VarnishCache_Model_Control_Catalog_Product
78
+ */
79
+ public function purgeById($id, $purgeParentProducts = false, $purgeCategories = false)
80
+ {
81
+ $product = Mage::getModel('catalog/product')->load($id);
82
+ return $this->purge($product, $purgeParentProducts, $purgeCategories);
83
+ }
84
+
85
+ /**
86
+ * Purge product by id
87
+ *
88
+ * @param int $id
89
+ * @return Phoenix_VarnishCache_Model_Control_Catalog_Product
90
+ */
91
+ protected function _purgeById($id)
92
+ {
93
+ $collection = $this->_getUrlRewriteCollection()
94
+ ->filterAllByProductId($id);
95
+ foreach ($collection as $urlRewriteRule) {
96
+ $urlRegexp = '/' . $urlRewriteRule->getRequestPath();
97
+ $this->_getCacheControl()
98
+ ->clean($this->_getStoreDomainList(), $urlRegexp);
99
+ }
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * Get Category Cache Control model
105
+ *
106
+ * @return Phoenix_VarnishCache_Model_Control_Catalog_Category
107
+ */
108
+ protected function _getCategoryCacheControl()
109
+ {
110
+ return Mage::getModel('varnishcache/control_catalog_category');
111
+ }
112
+ }
app/code/community/Phoenix/VarnishCache/Model/Control/Cms/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Control/Cms/Page.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Control_Cms_Page
22
+ extends Phoenix_VarnishCache_Model_Control_Abstract
23
+ {
24
+ const XML_PATH_WEB_DEFAULT_CMS_HOME_PAGE = 'web/default/cms_home_page';
25
+
26
+ protected $_helperName = 'varnishcache/control_cms_page';
27
+
28
+ /**
29
+ * Purge Cms Page
30
+ *
31
+ * @param Mage_Cms_Model_Page $page
32
+ * @return Phoenix_VarnishCache_Model_Control_Cms_Page
33
+ */
34
+ public function purge(Mage_Cms_Model_Page $page)
35
+ {
36
+ if ($this->_canPurge()) {
37
+
38
+ $storeIds = Mage::getResourceModel('varnishcache/cms_page_store_collection')
39
+ ->addPageFilter($page->getId())
40
+ ->getAllIds();
41
+
42
+ if (count($storeIds) && current($storeIds) == 0) {
43
+ $storeIds = Mage::getResourceModel('core/store_collection')
44
+ ->setWithoutDefaultFilter()
45
+ ->getAllIds();
46
+ }
47
+
48
+ foreach ($storeIds as $storeId) {
49
+ $url = Mage::app()->getStore($storeId)
50
+ ->getUrl(null, array('_direct' => $page->getIdentifier()));
51
+ extract(parse_url($url));
52
+ $path = rtrim($path, '/');
53
+ $this->_getCacheControl()->clean($host, '^' . $path . '/{0,1}$');
54
+
55
+ // Purge if current page is a home page
56
+ $homePageIdentifier
57
+ = Mage::getStoreConfig(self::XML_PATH_WEB_DEFAULT_CMS_HOME_PAGE, $storeId);
58
+ if ($page->getIdentifier() == $homePageIdentifier) {
59
+ $url = Mage::app()->getStore($storeId)
60
+ ->getUrl();
61
+ extract(parse_url($url));
62
+ $path = rtrim($path, '/');
63
+ $this->_getCacheControl()->clean($host, '^' . $path . '/{0,1}$');
64
+ $this->_getCacheControl()->clean($host, '^/{0,1}$');
65
+ }
66
+ }
67
+
68
+ $this->_getSession()->addSuccess(
69
+ Mage::helper('varnishcache')->__('Varnish cache for "%s" has been purged.', $page->getTitle())
70
+ );
71
+
72
+ }
73
+ return $this;
74
+ }
75
+
76
+ }
app/code/community/Phoenix/VarnishCache/Model/Observer.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Observer
22
+ {
23
+ const SET_CACHE_HEADER_FLAG = 'VARNISH_CACHE_CONTROL_HEADERS_SET';
24
+
25
+ /**
26
+ * Retrieve session model
27
+ *
28
+ * @return Mage_Adminhtml_Model_Session
29
+ */
30
+ protected function _getSession()
31
+ {
32
+ return Mage::getSingleton('adminhtml/session');
33
+ }
34
+
35
+ /**
36
+ * Check if full page cache is enabled
37
+ *
38
+ * @return bool
39
+ */
40
+ protected function _isCacheEnabled()
41
+ {
42
+ return Mage::helper('varnishcache')->isEnabled();
43
+ }
44
+
45
+ /**
46
+ * Get Varnish control model
47
+ *
48
+ * @return Phoenix_VarnishCache_Model_Control
49
+ */
50
+ protected function _getCacheControl()
51
+ {
52
+ return Mage::getSingleton('varnishcache/control');
53
+ }
54
+
55
+ /**
56
+ * Clean all Varnish cache items
57
+ *
58
+ * @param Varien_Event_Observer $observer
59
+ * @return Phoenix_VarnishCache_Model_Observer
60
+ */
61
+ public function cleanCache(Varien_Event_Observer $observer)
62
+ {
63
+ if ($this->_isCacheEnabled()) {
64
+ $this->_getCacheControl()->clean(Mage::helper('varnishcache/cache')->getStoreDomainList());
65
+
66
+ $this->_getSession()->addSuccess(
67
+ Mage::helper('varnishcache')->__('The Varnish cache has been cleaned.')
68
+ );
69
+ }
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * Clean media (CSS/JS) cache
75
+ *
76
+ * @param Varien_Event_Observer $observer
77
+ * @return Phoenix_VarnishCache_Model_Observer
78
+ */
79
+ public function cleanMediaCache(Varien_Event_Observer $observer)
80
+ {
81
+ if ($this->_isCacheEnabled()) {
82
+ $this->_getCacheControl()->clean(
83
+ Mage::helper('varnishcache/cache')->getStoreDomainList(),
84
+ '^/media/(js|css|css_secure)/'
85
+ );
86
+
87
+ // also clean HTML files
88
+ $this->_getCacheControl()->clean(
89
+ Mage::helper('varnishcache/cache')->getStoreDomainList(),
90
+ '.*',
91
+ Phoenix_VarnishCache_Model_Control::CONTENT_TYPE_HTML
92
+ );
93
+
94
+ $this->_getSession()->addSuccess(
95
+ Mage::helper('varnishcache')->__('The JavaScript/CSS cache has been cleaned on the Varnish servers.')
96
+ );
97
+ }
98
+ return $this;
99
+ }
100
+
101
+ /**
102
+ * Clean catalog images cache
103
+ *
104
+ * @param Varien_Event_Observer $observer
105
+ * @return Phoenix_VarnishCache_Model_Observer
106
+ */
107
+ public function cleanCatalogImagesCache(Varien_Event_Observer $observer)
108
+ {
109
+ if ($this->_isCacheEnabled()) {
110
+ $this->_getCacheControl()->clean(
111
+ Mage::helper('varnishcache/cache')->getStoreDomainList(),
112
+ '^/media/catalog/product/cache/',
113
+ Phoenix_VarnishCache_Model_Control::CONTENT_TYPE_IMAGE
114
+ );
115
+
116
+ // also clean HTML files
117
+ $this->_getCacheControl()->clean(
118
+ Mage::helper('varnishcache/cache')->getStoreDomainList(),
119
+ '.*',
120
+ Phoenix_VarnishCache_Model_Control::CONTENT_TYPE_HTML
121
+ );
122
+
123
+ $this->_getSession()->addSuccess(
124
+ Mage::helper('varnishcache')->__('The catalog image cache has been cleaned on the Varnish servers.')
125
+ );
126
+ }
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * Set appropriate cache control headers
132
+ *
133
+ * @param Varien_Event_Observer $observer
134
+ * @return Phoenix_VarnishCache_Model_Observer
135
+ */
136
+ public function setCacheControlHeaders(Varien_Event_Observer $observer)
137
+ {
138
+ if ($this->_isCacheEnabled()) {
139
+ if (!Mage::registry(self::SET_CACHE_HEADER_FLAG)) {
140
+ Mage::helper('varnishcache/cache')->setCacheControlHeaders();
141
+ Mage::register(self::SET_CACHE_HEADER_FLAG, true);
142
+ }
143
+ }
144
+ return $this;
145
+ }
146
+
147
+ /**
148
+ * If the page has been cached by the FPC and a NO_CACHE cookie has
149
+ * been set, the cached Cache-Control header might allow caching of the
150
+ * page while the NO_CACHE cookie which should prevent it.
151
+ * To sanitize this conflict we will force a TTL=0 before sending out
152
+ * the page.
153
+ */
154
+ public function sanitizeCacheControlHeader()
155
+ {
156
+ Mage::helper('varnishcache/cache')->sanitizeCacheControlHeader();
157
+ }
158
+
159
+ /**
160
+ * Disable page caching by setting no-cache header
161
+ *
162
+ * @param Varien_Event_Observer $observer | null
163
+ * @return Mage_PageCache_Model_Observer
164
+ */
165
+ public function disablePageCaching($observer = null)
166
+ {
167
+ if ($this->_isCacheEnabled() || Mage::app()->getStore()->isAdmin()) {
168
+ Mage::helper('varnishcache/cache')->setNoCacheHeader();
169
+ }
170
+ return $this;
171
+ }
172
+
173
+ /**
174
+ * Disable page caching for visitor by setting no-cache cookie
175
+ *
176
+ * @param Varien_Event_Observer $observer
177
+ * @return Mage_PageCache_Model_Observer
178
+ */
179
+ public function disablePageCachingPermanent($observer = null)
180
+ {
181
+ if ($this->_isCacheEnabled()) {
182
+ Mage::helper('varnishcache/cache')->setNoCacheCookie();
183
+ }
184
+ return $this;
185
+ }
186
+
187
+ /**
188
+ * Purge category
189
+ *
190
+ * @param Varien_Event_Observer $observer
191
+ * @return Phoenix_VarnishCache_Model_Observer
192
+ */
193
+ public function purgeCatalogCategory(Varien_Event_Observer $observer)
194
+ {
195
+ try {
196
+ $category = $observer->getEvent()->getCategory();
197
+ if (!Mage::registry('varnishcache_catalog_category_purged_' . $category->getId())) {
198
+ Mage::getModel('varnishcache/control_catalog_category')->purge($category);
199
+ Mage::register('varnishcache_catalog_category_purged_' . $category->getId(), true);
200
+ }
201
+ } catch (Exception $e) {
202
+ Mage::helper('varnishcache')->debug('Error on save category purging: '.$e->getMessage());
203
+ }
204
+ return $this;
205
+ }
206
+
207
+ /**
208
+ * Purge product
209
+ *
210
+ * @param Varien_Event_Observer $observer
211
+ * @return Phoenix_VarnishCache_Model_Observer
212
+ */
213
+ public function purgeCatalogProduct(Varien_Event_Observer $observer)
214
+ {
215
+ try {
216
+ $product = $observer->getEvent()->getProduct();
217
+ if (!Mage::registry('varnishcache_catalog_product_purged_' . $product->getId())) {
218
+ Mage::getModel('varnishcache/control_catalog_product')->purge($product, true, true);
219
+ Mage::register('varnishcache_catalog_product_purged_' . $product->getId(), true);
220
+ }
221
+ } catch (Exception $e) {
222
+ Mage::helper('varnishcache')->debug('Error on save product purging: '.$e->getMessage());
223
+ }
224
+ return $this;
225
+ }
226
+
227
+ /**
228
+ * Purge Cms Page
229
+ *
230
+ * @param Varien_Event_Observer $observer
231
+ * @return Phoenix_VarnishCache_Model_Observer
232
+ */
233
+ public function purgeCmsPage(Varien_Event_Observer $observer)
234
+ {
235
+ try {
236
+ $page = $observer->getEvent()->getObject();
237
+ if (!Mage::registry('varnishcache_cms_page_purged_' . $page->getId())) {
238
+ Mage::getModel('varnishcache/control_cms_page')->purge($page);
239
+ Mage::register('varnishcache_cms_page_purged_' . $page->getId(), true);
240
+ }
241
+ } catch (Exception $e) {
242
+ Mage::helper('varnishcache')->debug('Error on save cms page purging: '.$e->getMessage());
243
+ }
244
+ return $this;
245
+ }
246
+
247
+ /**
248
+ * Purge product
249
+ *
250
+ * @param Varien_Event_Observer $observer
251
+ * @return Phoenix_VarnishCache_Model_Observer
252
+ */
253
+ public function purgeCatalogProductByStock(Varien_Event_Observer $observer)
254
+ {
255
+ try {
256
+ $item = $observer->getEvent()->getItem();
257
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
258
+ if (!Mage::registry('varnishcache_catalog_product_purged_' . $product->getId())) {
259
+ Mage::getModel('varnishcache/control_catalog_product')->purge($product, true, true);
260
+ Mage::register('varnishcache_catalog_product_purged_' . $product->getId(), true);
261
+ }
262
+ } catch (Exception $e) {
263
+ Mage::helper('varnishcache')->debug('Error on save product purging: '.$e->getMessage());
264
+ }
265
+ return $this;
266
+ }
267
+ }
app/code/community/Phoenix/VarnishCache/Model/Processor.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Processor
22
+ {
23
+ /**
24
+ * This is only a dummy function at the moment to sanitize Cache-
25
+ * Control headers on FPC hits. It doesn't do what might be expected
26
+ * (retrieve cached content without ramping up the whole application
27
+ * stack), but it is the only way to hook in our logic.
28
+ *
29
+ * This method is called at the very beginning of Magento from
30
+ * Mage_Corel_Model_App::run() ->
31
+ * Mage_Core_Model_Cache::processRequest().
32
+ *
33
+ * @param string $content
34
+ * @return string | false
35
+ */
36
+ public function extractContent($content)
37
+ {
38
+ /**
39
+ * if content has been fetched from cache (FPC had a cache hit) the
40
+ * HTTP headers have been already set by the FPC. However if a
41
+ * NO_CACHE cookie is present we need to make sure the TTL is 0 as
42
+ * it might cache with a TTL > 0 which is a logical constraint.
43
+ */
44
+ if (!empty($content)) {
45
+ Phoenix_VarnishCache_Helper_Cache::sanitizeCacheControlHeader();
46
+ }
47
+ return $content;
48
+ }
49
+ }
app/code/community/Phoenix/VarnishCache/Model/Resource/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/Product.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Resource_Mysql4_Catalog_Category_Product
22
+ extends Mage_Core_Model_Mysql4_Abstract
23
+ {
24
+ /**
25
+ * Initialize resource model and define main table
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('catalog/category_product', 'category_id');
30
+ }
31
+ }
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/Product/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/Product/Collection.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Resource_Mysql4_Catalog_Category_Product_Collection
22
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
23
+ {
24
+ /**
25
+ * Initialize resource model and define main table
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('varnishcache/catalog_category_product');
30
+ }
31
+
32
+ /**
33
+ * Filter collection by product ids
34
+ *
35
+ * @param array $productIds
36
+ * @return Phoenix_VarnishCache_Model_Resource_Mysql4_Catalog_Category_Product_Collection
37
+ */
38
+ public function filterAllByProductIds(array $productIds)
39
+ {
40
+ $this->getSelect()
41
+ ->where('product_id in (?)', $productIds)
42
+ ->group('category_id');
43
+ return $this;
44
+ }
45
+ }
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Product/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Product/Relation/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Product/Relation/Collection.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Resource_Mysql4_Catalog_Product_Relation_Collection
22
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
23
+ {
24
+ /**
25
+ * Initialize resource model and define main table
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('varnishcache/catalog_product_relation', 'catalog/product_relation');
30
+ }
31
+
32
+ /**
33
+ * Filters collection by child product id
34
+ *
35
+ * @param int $childId
36
+ * @return Phoenix_VarnishCache_Model_Resource_Mysql4_Catalog_Product_Relation_Collection
37
+ */
38
+ public function filterByChildId($childId)
39
+ {
40
+ $this->getSelect()
41
+ ->where('child_id=?', $childId);
42
+ return $this;
43
+ }
44
+ }
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/Page/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/Page/Store.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Resource_Mysql4_Cms_Page_Store
22
+ extends Mage_Core_Model_Mysql4_Abstract
23
+ {
24
+ /**
25
+ * Initialize resource model and define main table
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('cms/page_store', 'store_id');
30
+ }
31
+ }
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/Page/Store/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Cms/Page/Store/Collection.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Resource_Mysql4_Cms_Page_Store_Collection
22
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
23
+ {
24
+ /**
25
+ * Initialize resource model and define main table
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('varnishcache/cms_page_store');
30
+ }
31
+
32
+ /**
33
+ * Add cms page id filter
34
+ *
35
+ * @param int $id
36
+ * @return Phoenix_VarnishCache_Model_Resource_Mysql4_Cms_Page_Store_Collection
37
+ */
38
+ public function addPageFilter($id)
39
+ {
40
+ $this->getSelect()
41
+ ->where('page_id = ?', $id);
42
+ return $this;
43
+ }
44
+ }
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Core/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Core/Url/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Core/Url/Rewrite/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Core/Url/Rewrite/Collection.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Model_Resource_Mysql4_Core_Url_Rewrite_Collection
22
+ extends Mage_Core_Model_Mysql4_Url_Rewrite_Collection
23
+ {
24
+ /**
25
+ * Filter collection by category id
26
+ *
27
+ * @param int $categoryId
28
+ * @return Phoenix_VarnishCache_Model_Resource_Mysql4_Core_Url_Rewrite_Collection
29
+ */
30
+ public function filterAllByCategoryId($categoryId)
31
+ {
32
+ $this->getSelect()
33
+ ->where('id_path = ?', "category/{$categoryId}");
34
+ return $this;
35
+ }
36
+ }
app/code/community/Phoenix/VarnishCache/controllers/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/controllers/Adminhtml/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/controllers/Adminhtml/VarnishCacheController.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category Phoenix
16
+ * @package Phoenix_VarnishCache
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ class Phoenix_VarnishCache_Adminhtml_VarnishCacheController
22
+ extends Mage_Adminhtml_Controller_Action
23
+ {
24
+ protected function _getSession()
25
+ {
26
+ return Mage::getSingleton('adminhtml/session');
27
+ }
28
+
29
+ public function cleanAction()
30
+ {
31
+ try {
32
+ if (Mage::helper('varnishcache')->isEnabled()) {
33
+ // get domains for purging
34
+ $domains = Mage::helper('varnishcache/cache')
35
+ ->getStoreDomainList($this->getRequest()->getParam('stores', 0));
36
+
37
+ // clean Varnish cache
38
+ Mage::getModel('varnishcache/control')
39
+ ->clean($domains, '.*', $this->getRequest()->getParam('content_types', '.*'));
40
+
41
+ $this->_getSession()->addSuccess(
42
+ Mage::helper('varnishcache')->__('The Varnish cache has been cleaned.')
43
+ );
44
+ }
45
+ }
46
+ catch (Mage_Core_Exception $e) {
47
+ $this->_getSession()->addError($e->getMessage());
48
+ }
49
+ catch (Exception $e) {
50
+ $this->_getSession()->addException(
51
+ $e,
52
+ Mage::helper('varnishcache')->__('An error occurred while clearing the Varnish cache.')
53
+ );
54
+ }
55
+ $this->_redirect('*/cache/index');
56
+ }
57
+ }
app/code/community/Phoenix/VarnishCache/etc/.DS_Store ADDED
Binary file
app/code/community/Phoenix/VarnishCache/etc/config.xml ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PageCache powered by Varnish
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to support@phoenix-media.eu so we can send you a copy immediately.
15
+ *
16
+ * @category Phoenix
17
+ * @package Phoenix_VarnishCache
18
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Phoenix_VarnishCache>
25
+ <version>3.0.0</version>
26
+ </Phoenix_VarnishCache>
27
+ </modules>
28
+ <global>
29
+ <models>
30
+ <varnishcache>
31
+ <class>Phoenix_VarnishCache_Model</class>
32
+ <resourceModel>varnishcache_resource_mysql4</resourceModel>
33
+ </varnishcache>
34
+ <varnishcache_resource_mysql4>
35
+ <class>Phoenix_VarnishCache_Model_Resource_Mysql4</class>
36
+ </varnishcache_resource_mysql4>
37
+ </models>
38
+ <helpers>
39
+ <varnishcache>
40
+ <class>Phoenix_VarnishCache_Helper</class>
41
+ </varnishcache>
42
+ </helpers>
43
+ <blocks>
44
+ <varnishcache>
45
+ <class>Phoenix_VarnishCache_Block</class>
46
+ </varnishcache>
47
+ </blocks>
48
+ <events>
49
+ <!-- purge product cache after stock upate -->
50
+ <cataloginventory_stock_item_save_after>
51
+ <observers>
52
+ <phoenix_varnishcache>
53
+ <class>varnishcache/observer</class>
54
+ <method>purgeCatalogProductByStock</method>
55
+ </phoenix_varnishcache>
56
+ </observers>
57
+ </cataloginventory_stock_item_save_after>
58
+ </events>
59
+ </global>
60
+ <admin>
61
+ <routers>
62
+ <adminhtml>
63
+ <args>
64
+ <modules>
65
+ <Phoenix_VarnishCache before="Mage_Adminhtml">Phoenix_VarnishCache_Adminhtml</Phoenix_VarnishCache>
66
+ </modules>
67
+ </args>
68
+ </adminhtml>
69
+ </routers>
70
+ </admin>
71
+ <adminhtml>
72
+ <layout>
73
+ <updates>
74
+ <varnishcache>
75
+ <file>varnishcache.xml</file>
76
+ </varnishcache>
77
+ </updates>
78
+ </layout>
79
+ <translate>
80
+ <modules>
81
+ <Phoenix_VarnishCache>
82
+ <files>
83
+ <default>Phoenix_VarnishCache.csv</default>
84
+ </files>
85
+ </Phoenix_VarnishCache>
86
+ </modules>
87
+ </translate>
88
+ <events>
89
+ <!-- disable page caching for all admin requests -->
90
+ <controller_action_predispatch_adminhtml>
91
+ <observers>
92
+ <varnishcache>
93
+ <class>varnishcache/observer</class>
94
+ <method>disablePageCaching</method>
95
+ </varnishcache>
96
+ </observers>
97
+ </controller_action_predispatch_adminhtml>
98
+
99
+ <!-- clean varnish page cache together with magento -->
100
+ <controller_action_postdispatch_adminhtml_cache_flushAll>
101
+ <observers>
102
+ <varnishcache>
103
+ <type>singleton</type>
104
+ <class>varnishcache/observer</class>
105
+ <method>cleanCache</method>
106
+ </varnishcache>
107
+ </observers>
108
+ </controller_action_postdispatch_adminhtml_cache_flushAll>
109
+ <controller_action_postdispatch_adminhtml_cache_flushSystem>
110
+ <observers>
111
+ <varnishcache>
112
+ <type>singleton</type>
113
+ <class>varnishcache/observer</class>
114
+ <method>cleanCache</method>
115
+ </varnishcache>
116
+ </observers>
117
+ </controller_action_postdispatch_adminhtml_cache_flushSystem>
118
+
119
+ <!-- clean varnish js/css cache together with magento -->
120
+ <clean_media_cache_after>
121
+ <observers>
122
+ <enterprise_pagecache>
123
+ <class>varnishcache/observer</class>
124
+ <method>cleanMediaCache</method>
125
+ </enterprise_pagecache>
126
+ </observers>
127
+ </clean_media_cache_after>
128
+
129
+ <!-- clean varnish catalog images cache together with magento -->
130
+ <clean_catalog_images_cache_after>
131
+ <observers>
132
+ <enterprise_pagecache>
133
+ <class>varnishcache/observer</class>
134
+ <method>cleanCatalogImagesCache</method>
135
+ </enterprise_pagecache>
136
+ </observers>
137
+ </clean_catalog_images_cache_after>
138
+
139
+ <!-- purge category cache after save -->
140
+ <catalog_category_save_after>
141
+ <observers>
142
+ <phoenix_varnishcache>
143
+ <class>varnishcache/observer</class>
144
+ <method>purgeCatalogCategory</method>
145
+ </phoenix_varnishcache>
146
+ </observers>
147
+ </catalog_category_save_after>
148
+
149
+ <!-- purge product cache after save -->
150
+ <catalog_product_save_after>
151
+ <observers>
152
+ <phoenix_varnishcache>
153
+ <class>varnishcache/observer</class>
154
+ <method>purgeCatalogProduct</method>
155
+ </phoenix_varnishcache>
156
+ </observers>
157
+ </catalog_product_save_after>
158
+
159
+ <!-- purge cms page cache after save -->
160
+ <cms_page_save_after>
161
+ <observers>
162
+ <phoenix_varnishcache>
163
+ <class>varnishcache/observer</class>
164
+ <method>purgeCmsPage</method>
165
+ </phoenix_varnishcache>
166
+ </observers>
167
+ </cms_page_save_after>
168
+ </events>
169
+ </adminhtml>
170
+ <frontend>
171
+ <events>
172
+ <!-- add cache headers -->
173
+ <controller_action_postdispatch>
174
+ <observers>
175
+ <varnishcache>
176
+ <class>varnishcache/observer</class>
177
+ <method>setCacheControlHeaders</method>
178
+ </varnishcache>
179
+ </observers>
180
+ </controller_action_postdispatch>
181
+ <http_response_send_before>
182
+ <observers>
183
+ <varnishcache>
184
+ <class>varnishcache/observer</class>
185
+ <method>sanitizeCacheControlHeader</method>
186
+ </varnishcache>
187
+ </observers>
188
+ </http_response_send_before>
189
+
190
+ <!-- stop page caching at visitor interaction -->
191
+ <core_session_abstract_add_message>
192
+ <observers>
193
+ <varnishcache>
194
+ <class>varnishcache/observer</class>
195
+ <method>disablePageCachingPermanent</method>
196
+ </varnishcache>
197
+ </observers>
198
+ </core_session_abstract_add_message>
199
+ <checkout_cart_product_add_after>
200
+ <observers>
201
+ <varnishcache>
202
+ <class>varnishcache/observer</class>
203
+ <method>disablePageCachingPermanent</method>
204
+ </varnishcache>
205
+ </observers>
206
+ </checkout_cart_product_add_after>
207
+ <customer_login>
208
+ <observers>
209
+ <varnishcache>
210
+ <class>varnishcache/observer</class>
211
+ <method>disablePageCachingPermanent</method>
212
+ </varnishcache>
213
+ </observers>
214
+ </customer_login>
215
+ <catalog_product_compare_add_product>
216
+ <observers>
217
+ <varnishcache>
218
+ <class>varnishcache/observer</class>
219
+ <method>disablePageCachingPermanent</method>
220
+ </varnishcache>
221
+ </observers>
222
+ </catalog_product_compare_add_product>
223
+ <wishlist_add_product>
224
+ <observers>
225
+ <varnishcache>
226
+ <class>varnishcache/observer</class>
227
+ <method>disablePageCachingPermanent</method>
228
+ </varnishcache>
229
+ </observers>
230
+ </wishlist_add_product>
231
+ </events>
232
+ </frontend>
233
+ <default>
234
+ <system>
235
+ <varnishcache>
236
+ <enabled>0</enabled>
237
+ <servers>localhost</servers>
238
+ <port>80</port>
239
+ <disable_caching>0</disable_caching>
240
+ <disable_routes>
241
+ <![CDATA[checkout
242
+ customer
243
+ moneybookers
244
+ paypal
245
+ wishlist]]></disable_routes>
246
+ <disable_caching_vars><![CDATA[___store,___SID,currency,order]]></disable_caching_vars>
247
+ <ttl>14400</ttl>
248
+ <routes_ttl>a:3:{s:1:"1";a:2:{s:6:"regexp";s:3:"cms";s:5:"value";s:5:"86400";}s:1:"2";a:2:{s:6:"regexp";s:20:"catalog_product_view";s:5:"value";s:4:"7200";}s:1:"3";a:2:{s:6:"regexp";s:16:"catalog_category";s:5:"value";s:5:"21600";}}</routes_ttl>
249
+ <purge_catalog_category>0</purge_catalog_category>
250
+ <purge_catalog_product>0</purge_catalog_product>
251
+ <purge_cms_page>0</purge_cms_page>
252
+ <debug>0</debug>
253
+ </varnishcache>
254
+ </system>
255
+ </default>
256
+ </config>
app/code/community/Phoenix/VarnishCache/etc/default_2.1.vcl ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This is a basic VCL configuration file for PageCache powered by Varnish for Magento module.
2
+
3
+ # default backend definition. Set this to point to your content server.
4
+ backend default {
5
+ .host = "127.0.0.1";
6
+ .port = "8080";
7
+ }
8
+
9
+ # add your Magento server IP to allow purges from the backend
10
+ acl purge {
11
+ "localhost";
12
+ "127.0.0.1";
13
+ }
14
+
15
+
16
+ sub vcl_recv {
17
+ if (req.restarts == 0) {
18
+ if (req.http.x-forwarded-for) {
19
+ set req.http.X-Forwarded-For =
20
+ req.http.X-Forwarded-For ", " client.ip;
21
+ } else {
22
+ set req.http.X-Forwarded-For = client.ip;
23
+ }
24
+ }
25
+
26
+ if (req.request != "GET" &&
27
+ req.request != "HEAD" &&
28
+ req.request != "PUT" &&
29
+ req.request != "POST" &&
30
+ req.request != "TRACE" &&
31
+ req.request != "OPTIONS" &&
32
+ req.request != "DELETE" &&
33
+ req.request != "PURGE") {
34
+ /* Non-RFC2616 or CONNECT which is weird. */
35
+ return (pipe);
36
+ }
37
+
38
+ # purge request
39
+ if (req.request == "PURGE") {
40
+ if (!client.ip ~ purge) {
41
+ error 405 "Not allowed.";
42
+ }
43
+ purge("obj.http.X-Purge-Host ~ " req.http.X-Purge-Host " && obj.http.X-Purge-URL ~ " req.http.X-Purge-Regex " && obj.http.Content-Type ~ " req.http.X-Purge-Content-Type);
44
+ error 200 "Purged.";
45
+ }
46
+
47
+ # we only deal with GET and HEAD by default
48
+ if (req.request != "GET" && req.request != "HEAD") {
49
+ return (pass);
50
+ }
51
+
52
+ # static files are always cacheable. remove SSL flag and cookie
53
+ if (req.url ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$") {
54
+ unset req.http.Https;
55
+ unset req.http.Cookie;
56
+ }
57
+
58
+ # not cacheable by default
59
+ if (req.http.Authorization || req.http.Https) {
60
+ return (pass);
61
+ }
62
+
63
+ # do not cache any page from
64
+ # - index files
65
+ # - ...
66
+ if (req.url ~ "^/(index)") {
67
+ return (pass);
68
+ }
69
+
70
+ # as soon as we have a NO_CACHE cookie pass request
71
+ if (req.http.cookie ~ "NO_CACHE=") {
72
+ return (pass);
73
+ }
74
+
75
+ # normalize Aceept-Encoding header
76
+ # http://varnish.projects.linpro.no/wiki/FAQ/Compression
77
+ if (req.http.Accept-Encoding) {
78
+ if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
79
+ # No point in compressing these
80
+ remove req.http.Accept-Encoding;
81
+ } elsif (req.http.Accept-Encoding ~ "gzip") {
82
+ set req.http.Accept-Encoding = "gzip";
83
+ } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
84
+ set req.http.Accept-Encoding = "deflate";
85
+ } else {
86
+ # unkown algorithm
87
+ remove req.http.Accept-Encoding;
88
+ }
89
+ }
90
+
91
+ # remove Google gclid parameters
92
+ set req.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA"
93
+ set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar"
94
+ set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"
95
+
96
+ return (lookup);
97
+ }
98
+
99
+ # sub vcl_pipe {
100
+ # # Note that only the first request to the backend will have
101
+ # # X-Forwarded-For set. If you use X-Forwarded-For and want to
102
+ # # have it set for all requests, make sure to have:
103
+ # # set bereq.http.connection = "close";
104
+ # # here. It is not set by default as it might break some broken web
105
+ # # applications, like IIS with NTLM authentication.
106
+ # return (pipe);
107
+ # }
108
+ #
109
+ # sub vcl_pass {
110
+ # return (pass);
111
+ # }
112
+ #
113
+ sub vcl_hash {
114
+ set req.hash += req.url;
115
+ if (req.http.host) {
116
+ set req.hash += req.http.host;
117
+ } else {
118
+ set req.hash += server.ip;
119
+ }
120
+ if (!(req.url ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$")) {
121
+ call design_exception;
122
+ }
123
+ return (hash);
124
+ }
125
+ #
126
+ # sub vcl_hit {
127
+ # if (!obj.cacheable) {
128
+ # return (pass);
129
+ # }
130
+ # return (deliver);
131
+ # }
132
+ #
133
+ # sub vcl_miss {
134
+ # return (fetch);
135
+ # }
136
+
137
+ sub vcl_fetch {
138
+ if (beresp.status == 500) {
139
+ set beresp.saintmode = 10s;
140
+ restart;
141
+ }
142
+ set beresp.grace = 5m;
143
+
144
+ # add ban-lurker tags to object
145
+ set beresp.http.X-Purge-URL = req.url;
146
+ set beresp.http.X-Purge-Host = req.http.host;
147
+
148
+ if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {
149
+ if (beresp.http.Content-Type ~ "text/html" || beresp.http.Content-Type ~ "text/xml") {
150
+ if ((beresp.http.Set-Cookie ~ "NO_CACHE=") || (beresp.ttl < 1s)) {
151
+ set beresp.ttl = 0s;
152
+ return (pass);
153
+ }
154
+
155
+ # marker for vcl_deliver to reset Age:
156
+ set beresp.http.magicmarker = "1";
157
+
158
+ # Don't cache cookies
159
+ unset beresp.http.set-cookie;
160
+ } else {
161
+ # set default TTL value for static content
162
+ set beresp.ttl = 4h;
163
+ }
164
+ return (deliver);
165
+ }
166
+ return (pass);
167
+ }
168
+
169
+ sub vcl_deliver {
170
+ # debug info
171
+ if (resp.http.X-Cache-Debug) {
172
+ if (obj.hits > 0) {
173
+ set resp.http.X-Cache = "HIT";
174
+ set resp.http.X-Cache-Hits = obj.hits;
175
+ } else {
176
+ set resp.http.X-Cache = "MISS";
177
+ }
178
+ set resp.http.X-Cache-Expires = resp.http.Expires;
179
+ } else {
180
+ # remove Varnish/proxy header
181
+ remove resp.http.X-Varnish;
182
+ remove resp.http.Via;
183
+ remove resp.http.Age;
184
+ remove resp.http.X-Purge-URL;
185
+ remove resp.http.X-Purge-Host;
186
+ }
187
+
188
+ if (resp.http.magicmarker) {
189
+ # Remove the magic marker
190
+ unset resp.http.magicmarker;
191
+
192
+ set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
193
+ set resp.http.Pragma = "no-cache";
194
+ set resp.http.Expires = "Mon, 31 Mar 2008 10:00:00 GMT";
195
+ set resp.http.Age = "0";
196
+ }
197
+ }
198
+
199
+ # sub vcl_error {
200
+ # set obj.http.Content-Type = "text/html; charset=utf-8";
201
+ # synthetic {"
202
+ # <?xml version="1.0" encoding="utf-8"?>
203
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
204
+ # "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
205
+ # <html>
206
+ # <head>
207
+ # <title>"} obj.status " " obj.response {"</title>
208
+ # </head>
209
+ # <body>
210
+ # <h1>Error "} obj.status " " obj.response {"</h1>
211
+ # <p>"} obj.response {"</p>
212
+ # <h3>Guru Meditation:</h3>
213
+ # <p>XID: "} req.xid {"</p>
214
+ # <hr>
215
+ # <p>Varnish cache server</p>
216
+ # </body>
217
+ # </html>
218
+ # "};
219
+ # return (deliver);
220
+ # }
221
+
222
+ sub design_exception {
223
+ }
app/code/community/Phoenix/VarnishCache/etc/default_3.0.vcl ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This is a basic VCL configuration file for PageCache powered by Varnish for Magento module.
2
+
3
+ # default backend definition. Set this to point to your content server.
4
+ backend default {
5
+ .host = "127.0.0.1";
6
+ .port = "8080";
7
+ }
8
+
9
+ # add your Magento server IP to allow purges from the backend
10
+ acl purge {
11
+ "localhost";
12
+ "127.0.0.1";
13
+ }
14
+
15
+
16
+ sub vcl_recv {
17
+ if (req.restarts == 0) {
18
+ if (req.http.x-forwarded-for) {
19
+ set req.http.X-Forwarded-For =
20
+ req.http.X-Forwarded-For + ", " + client.ip;
21
+ } else {
22
+ set req.http.X-Forwarded-For = client.ip;
23
+ }
24
+ }
25
+
26
+ if (req.request != "GET" &&
27
+ req.request != "HEAD" &&
28
+ req.request != "PUT" &&
29
+ req.request != "POST" &&
30
+ req.request != "TRACE" &&
31
+ req.request != "OPTIONS" &&
32
+ req.request != "DELETE" &&
33
+ req.request != "PURGE") {
34
+ /* Non-RFC2616 or CONNECT which is weird. */
35
+ return (pipe);
36
+ }
37
+
38
+ # purge request
39
+ if (req.request == "PURGE") {
40
+ if (!client.ip ~ purge) {
41
+ error 405 "Not allowed.";
42
+ }
43
+ ban("obj.http.X-Purge-Host ~ " + req.http.X-Purge-Host + " && obj.http.X-Purge-URL ~ " + req.http.X-Purge-Regex + " && obj.http.Content-Type ~ " + req.http.X-Purge-Content-Type);
44
+ error 200 "Purged.";
45
+ }
46
+
47
+ # we only deal with GET and HEAD by default
48
+ if (req.request != "GET" && req.request != "HEAD") {
49
+ return (pass);
50
+ }
51
+
52
+ # static files are always cacheable. remove SSL flag and cookie
53
+ if (req.url ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$") {
54
+ unset req.http.Https;
55
+ unset req.http.Cookie;
56
+ }
57
+
58
+ # not cacheable by default
59
+ if (req.http.Authorization || req.http.Https) {
60
+ return (pass);
61
+ }
62
+
63
+ # do not cache any page from
64
+ # - index files
65
+ # - ...
66
+ if (req.url ~ "^/(index)") {
67
+ return (pass);
68
+ }
69
+
70
+ # as soon as we have a NO_CACHE cookie pass request
71
+ if (req.http.cookie ~ "NO_CACHE=") {
72
+ return (pass);
73
+ }
74
+
75
+ # normalize Aceept-Encoding header
76
+ # http://varnish.projects.linpro.no/wiki/FAQ/Compression
77
+ if (req.http.Accept-Encoding) {
78
+ if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
79
+ # No point in compressing these
80
+ remove req.http.Accept-Encoding;
81
+ } elsif (req.http.Accept-Encoding ~ "gzip") {
82
+ set req.http.Accept-Encoding = "gzip";
83
+ } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
84
+ set req.http.Accept-Encoding = "deflate";
85
+ } else {
86
+ # unkown algorithm
87
+ remove req.http.Accept-Encoding;
88
+ }
89
+ }
90
+
91
+ # remove Google gclid parameters
92
+ set req.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA"
93
+ set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar"
94
+ set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"
95
+
96
+ return (lookup);
97
+ }
98
+
99
+ # sub vcl_pipe {
100
+ # # Note that only the first request to the backend will have
101
+ # # X-Forwarded-For set. If you use X-Forwarded-For and want to
102
+ # # have it set for all requests, make sure to have:
103
+ # # set bereq.http.connection = "close";
104
+ # # here. It is not set by default as it might break some broken web
105
+ # # applications, like IIS with NTLM authentication.
106
+ # return (pipe);
107
+ # }
108
+ #
109
+ # sub vcl_pass {
110
+ # return (pass);
111
+ # }
112
+ #
113
+ sub vcl_hash {
114
+ hash_data(req.url);
115
+ if (req.http.host) {
116
+ hash_data(req.http.host);
117
+ } else {
118
+ hash_data(server.ip);
119
+ }
120
+ if (!(req.url ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$")) {
121
+ call design_exception;
122
+ }
123
+ return (hash);
124
+ }
125
+ #
126
+ # sub vcl_hit {
127
+ # return (deliver);
128
+ # }
129
+ #
130
+ # sub vcl_miss {
131
+ # return (fetch);
132
+ # }
133
+
134
+ sub vcl_fetch {
135
+ if (beresp.status == 500) {
136
+ set beresp.saintmode = 10s;
137
+ return (restart);
138
+ }
139
+ set beresp.grace = 5m;
140
+
141
+ # add ban-lurker tags to object
142
+ set beresp.http.X-Purge-URL = req.url;
143
+ set beresp.http.X-Purge-Host = req.http.host;
144
+
145
+ if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {
146
+ if (beresp.http.Content-Type ~ "text/html" || beresp.http.Content-Type ~ "text/xml") {
147
+ if ((beresp.http.Set-Cookie ~ "NO_CACHE=") || (beresp.ttl < 1s)) {
148
+ set beresp.ttl = 0s;
149
+ return (hit_for_pass);
150
+ }
151
+
152
+ # marker for vcl_deliver to reset Age:
153
+ set beresp.http.magicmarker = "1";
154
+
155
+ # Don't cache cookies
156
+ unset beresp.http.set-cookie;
157
+ } else {
158
+ # set default TTL value for static content
159
+ set beresp.ttl = 4h;
160
+ }
161
+ return (deliver);
162
+ }
163
+
164
+ return (hit_for_pass);
165
+ }
166
+
167
+ sub vcl_deliver {
168
+ # debug info
169
+ if (resp.http.X-Cache-Debug) {
170
+ if (obj.hits > 0) {
171
+ set resp.http.X-Cache = "HIT";
172
+ set resp.http.X-Cache-Hits = obj.hits;
173
+ } else {
174
+ set resp.http.X-Cache = "MISS";
175
+ }
176
+ set resp.http.X-Cache-Expires = resp.http.Expires;
177
+ } else {
178
+ # remove Varnish/proxy header
179
+ remove resp.http.X-Varnish;
180
+ remove resp.http.Via;
181
+ remove resp.http.Age;
182
+ remove resp.http.X-Purge-URL;
183
+ remove resp.http.X-Purge-Host;
184
+ }
185
+
186
+ if (resp.http.magicmarker) {
187
+ # Remove the magic marker
188
+ unset resp.http.magicmarker;
189
+
190
+ set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
191
+ set resp.http.Pragma = "no-cache";
192
+ set resp.http.Expires = "Mon, 31 Mar 2008 10:00:00 GMT";
193
+ set resp.http.Age = "0";
194
+ }
195
+ }
196
+
197
+ # sub vcl_error {
198
+ # set obj.http.Content-Type = "text/html; charset=utf-8";
199
+ # set obj.http.Retry-After = "5";
200
+ # synthetic {"
201
+ # <?xml version="1.0" encoding="utf-8"?>
202
+ # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
203
+ # "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
204
+ # <html>
205
+ # <head>
206
+ # <title>"} + obj.status + " " + obj.response + {"</title>
207
+ # </head>
208
+ # <body>
209
+ # <h1>Error "} + obj.status + " " + obj.response + {"</h1>
210
+ # <p>"} + obj.response + {"</p>
211
+ # <h3>Guru Meditation:</h3>
212
+ # <p>XID: "} + req.xid + {"</p>
213
+ # <hr>
214
+ # <p>Varnish cache server</p>
215
+ # </body>
216
+ # </html>
217
+ # "};
218
+ # return (deliver);
219
+ # }
220
+ #
221
+ # sub vcl_init {
222
+ # return (ok);
223
+ # }
224
+ #
225
+ # sub vcl_fini {
226
+ # return (ok);
227
+ # }
228
+
229
+ sub design_exception {
230
+ }
app/code/community/Phoenix/VarnishCache/etc/system.xml ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PageCache powered by Varnish
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to support@phoenix-media.eu so we can send you a copy immediately.
15
+ *
16
+ * @category Phoenix
17
+ * @package Phoenix_VarnishCache
18
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <sections>
24
+ <system>
25
+ <groups>
26
+ <varnishcache translate="label comment" module="varnishcache">
27
+ <label>PageCache powered by Varnish settings</label>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <sort_order>900</sort_order>
32
+ <fields>
33
+ <versioninfo>
34
+ <frontend_model>varnishcache/adminhtml_system_config_fieldset_versioninfo</frontend_model>
35
+ <sort_order>0</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </versioninfo>
40
+ <enabled translate="label comment">
41
+ <label>Enable cache module</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>10</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </enabled>
49
+ <servers translate="label comment">
50
+ <label>Varnish servers</label>
51
+ <comment>Domain or IP list separted by semicolon (e.g. host1;127.0.0.1)</comment>
52
+ <frontend_type>text</frontend_type>
53
+ <sort_order>20</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>0</show_in_website>
56
+ <show_in_store>0</show_in_store>
57
+ <depends><enabled>1</enabled></depends>
58
+ </servers>
59
+ <port translate="label comment">
60
+ <label>Server port</label>
61
+ <comment>Port of the Varnish servers (e.g. 8080)</comment>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>30</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>0</show_in_website>
66
+ <show_in_store>0</show_in_store>
67
+ <depends><enabled>1</enabled></depends>
68
+ </port>
69
+ <disable_caching translate="label comment">
70
+ <label>Disable caching</label>
71
+ <comment>Set a TTL of "0" for every request</comment>
72
+ <frontend_type>select</frontend_type>
73
+ <source_model>adminhtml/system_config_source_yesno</source_model>
74
+ <sort_order>40</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ <depends><enabled>1</enabled></depends>
79
+ </disable_caching>
80
+ <disable_routes translate="label comment">
81
+ <label>Disable caching for routes</label>
82
+ <comment>Set a TTL of "0" for certain routes/actions (e.g. checkout, catalog_product_view). Use one per line.</comment>
83
+ <frontend_type>textarea</frontend_type>
84
+ <sort_order>50</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ <depends><enabled>1</enabled></depends>
89
+ </disable_routes>
90
+ <disable_caching_vars translate="label comment">
91
+ <label>Disable caching vars</label>
92
+ <comment>Request variables that force setting of NO_CACHE cookie to permanent disable caching for visitor.</comment>
93
+ <frontend_type>text</frontend_type>
94
+ <sort_order>60</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ <depends><enabled>1</enabled></depends>
99
+ </disable_caching_vars>
100
+ <ttl translate="label comment">
101
+ <label>Default cache TTL</label>
102
+ <comment>TTL for cached pages in seconds (e.g. "1800" = page cache is valid for 30 minutes).</comment>
103
+ <frontend_type>text</frontend_type>
104
+ <sort_order>70</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ <depends><enabled>1</enabled></depends>
109
+ </ttl>
110
+ <routes_ttl translate="label comment">
111
+ <label>Cache TTL for routes</label>
112
+ <comment>TTL for cached pages in seconds for certain routes/actions (e.g. Route:"catalog_product_view", TTL:"7200").</comment>
113
+ <frontend_type>textarea</frontend_type>
114
+ <frontend_model>varnishcache/adminhtml_system_config_fieldset_routeTTL</frontend_model>
115
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
116
+ <sort_order>80</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ <depends><enabled>1</enabled></depends>
121
+ </routes_ttl>
122
+ <purge_catalog_category translate="label comment">
123
+ <label>Purge category</label>
124
+ <comment>Purge categorie's cache item on save</comment>
125
+ <frontend_type>select</frontend_type>
126
+ <source_model>adminhtml/system_config_source_yesno</source_model>
127
+ <sort_order>110</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>1</show_in_store>
131
+ <depends><enabled>1</enabled></depends>
132
+ </purge_catalog_category>
133
+ <purge_catalog_product translate="label comment">
134
+ <label>Purge product</label>
135
+ <comment>Purge product's cache item on save</comment>
136
+ <frontend_type>select</frontend_type>
137
+ <source_model>adminhtml/system_config_source_yesno</source_model>
138
+ <sort_order>120</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>1</show_in_store>
142
+ <depends><enabled>1</enabled></depends>
143
+ </purge_catalog_product>
144
+ <purge_cms_page translate="label comment">
145
+ <label>Purge CMS page</label>
146
+ <comment>Purge CMS page's cache item on save</comment>
147
+ <frontend_type>select</frontend_type>
148
+ <source_model>adminhtml/system_config_source_yesno</source_model>
149
+ <sort_order>130</sort_order>
150
+ <show_in_default>1</show_in_default>
151
+ <show_in_website>1</show_in_website>
152
+ <show_in_store>1</show_in_store>
153
+ <depends><enabled>1</enabled></depends>
154
+ </purge_cms_page>
155
+ <debug translate="label comment">
156
+ <label>Debug</label>
157
+ <comment>Pass X-headers for debugging purpose to the client and log purge requests to /var/log/varnish_cache.log (ensure developer log is enabled).</comment>
158
+ <frontend_type>select</frontend_type>
159
+ <source_model>adminhtml/system_config_source_yesno</source_model>
160
+ <sort_order>300</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <show_in_store>1</show_in_store>
164
+ <depends><enabled>1</enabled></depends>
165
+ </debug>
166
+ </fields>
167
+ </varnishcache>
168
+ </groups>
169
+ </system>
170
+ </sections>
171
+ </config>
app/design/adminhtml/default/default/layout/varnishcache.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PageCache powered by Varnish
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to support@phoenix-media.eu so we can send you a copy immediately.
15
+ *
16
+ * @category design
17
+ * @package default_default
18
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+
23
+ <layout>
24
+ <adminhtml_cache_index>
25
+ <reference name="content">
26
+ <block type="varnishcache/adminhtml_cache_additional" name="varnish.cache.additional" template="varnishcache/cache/additional.phtml" after="cache.additional" />
27
+ </reference>
28
+ </adminhtml_cache_index>
29
+ </layout>
app/design/adminhtml/default/default/template/varnishcache/.DS_Store ADDED
Binary file
app/design/adminhtml/default/default/template/varnishcache/cache/.DS_Store ADDED
Binary file
app/design/adminhtml/default/default/template/varnishcache/cache/additional.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PageCache powered by Varnish
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to support@phoenix-media.eu so we can send you a copy immediately.
14
+ *
15
+ * @category design
16
+ * @package default_default
17
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+
22
+ <?php if ($this->canShowButton()): ?>
23
+ <form action="<?php echo $this->getCleanVarnishCacheUrl() ?>" method="post" id="varnish_clean_form" enctype="multipart/form-data">
24
+ <?php echo $this->getBlockHtml('formkey')?>
25
+ <table class="form-list">
26
+ <tr>
27
+ <td class="scope-label">
28
+ <button type="submit" class="scalable"><span><?php echo Mage::helper('varnishcache')->__('Clean Varnish Cache') ?></span></button>
29
+ </td>
30
+ <td>
31
+ <select name="stores" class="required-entry select local-validation" style="width:150px">
32
+ <?php foreach ($this->getStoreOptions() as $store): ?>
33
+ <option value="<?php echo $store['value'] ?>"><?php echo $this->escapeHtml($store['label'],true) ?></option>
34
+ <?php endforeach; ?>
35
+ </select>
36
+ </td>
37
+ <td>
38
+ <select name="content_types" class="required-entry select local-validation" style="width:150px">
39
+ <?php foreach ($this->getContentTypeOptions() as $contentType): ?>
40
+ <option value="<?php echo $contentType['value'] ?>"><?php echo $this->escapeHtml($contentType['label']) ?></option>
41
+ <?php endforeach; ?>
42
+ </select>
43
+ </td>
44
+ <td class="scope-label">
45
+ <?php echo Mage::helper('varnishcache')->__('Remove selected cache items in external Varnish cache.')?>
46
+ </td>
47
+ </tr>
48
+ </table>
49
+ </form>
50
+ <?php endif;?>
app/etc/modules/Phoenix_VarnishCache.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PageCache powered by Varnish
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to support@phoenix-media.eu so we can send you a copy immediately.
15
+ *
16
+ * @category Phoenix
17
+ * @package Phoenix_VarnishCache
18
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Phoenix_VarnishCache>
25
+ <active>true</active>
26
+ <codePool>community</codePool>
27
+ </Phoenix_VarnishCache>
28
+ </modules>
29
+ </config>
app/etc/varnishcache.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <!--
3
+ /**
4
+ * PageCache powered by Varnish
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to support@phoenix-media.eu so we can send you a copy immediately.
15
+ *
16
+ * @category Phoenix
17
+ * @package Phoenix_VarnishCache
18
+ * @copyright Copyright (c) 2011 PHOENIX MEDIA GmbH & Co. KG (http://www.phoenix-media.de)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <global>
24
+ <cache>
25
+ <request_processors>
26
+ <varnishcache>Phoenix_VarnishCache_Model_Processor</varnishcache>
27
+ </request_processors>
28
+ </cache>
29
+ </global>
30
+ </config>
app/locale/de_DE/Phoenix_VarnishCache.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "All content types","Alle Content-Types"
2
+ "All stores","Alle Stores"
3
+ "An error occurred while clearing the Varnish cache.","Beim Leeren des Varnish Caches trat ein Fehler auf."
4
+ "CSS","CSS"
5
+ "Clean Varnish Cache","Varnish Cache leeren"
6
+ "Debug","Debug"
7
+ "Disable caching","Caching deaktivieren"
8
+ "Disable caching for routes","Caching für Routen deaktivieren"
9
+ "Disable caching vars","Cache-Deaktivierungs-Variablen"
10
+ "Domain or IP list separted by semicolon (e.g. host1;127.0.0.1)","Domänen- oder IP-Liste getrennt durch Strichpunkt (z.B. server1;127.0.0.1)"
11
+ "Enable cache module","Aktiviere Caching Modul"
12
+ "HTML","HTML"
13
+ "If you see this message everything is fine.","Wenn Sie diese Nachricht sehen ist alles in Ordnung."
14
+ "Images","Bilder"
15
+ "JavaScript","JavaScript"
16
+ "PageCache powered by Varnish version: %s","PageCache powered by Varnish Version: %s"
17
+ "Pass X-headers for debugging purpose to the client and log purge requests to /var/log/varnish_cache.log (ensure developer log is enabled).","X-Header für Debugging an den Client weitergeben und PURGE-Requests in /var/log/varnish_cache.log schreiben (Entwickler-Log muss aktiviert sein)."
18
+ "Port of the Varnish servers (e.g. 8080)","Port der Varnish Server (e.g. 8080)"
19
+ "Remove selected cache items in external Varnish cache.","Entfernung ausgewählter Objekte aus dem externen Varnish Cache."
20
+ "Request variables that force setting of NO_CACHE cookie to permanent disable caching for visitor.","GET-Variablen, die das Setzen des NO_CACHE Cookies erzwingen, um das Caching für den Besucher dauerhaft zu deaktivieren."
21
+ "Server port","Server Port"
22
+ "Set ""no-cache"" HTTP header for certain routes/actions (e.g. checkout, catalog_product_view). Use one per line.","Setzt ""no-cache"" HTTP-Header für bestimmte Routen/Actions (e.g. checkout, catalog_product_view). Eine Zeile je Angabe."
23
+ "Cache TTL for routes","Cache-TTL für Routen"
24
+ "Set a TTL of ""0"" for every request","Setzt einen TTL von ""0"" für jede Anfrage"
25
+ "TTL for cached pages in seconds for certain routes/actions (e.g. Route:""catalog_product_view"", TTL:""7200"").","TTL für gecachte Seiten in Sekunden (z.B. Route:""catalog_product_view"", TTL:""7200"")."
26
+ "TTL for cached pages in seconds (e.g. ""1800"" = page cache is valid for 30 minutes).","TTL für gecachte Seiten in Sekunden (z.B. ""1800"" = Seiten-Cache ist für 30 Minuten gültig)."
27
+ "The JavaScript/CSS cache has been cleaned on the Varnish servers.","Der JavaScript/CSS Cache wurde in den Varnish Servern geleert."
28
+ "The Varnish cache has been cleaned.","Der Varnish Cache wurde geleert."
29
+ "The catalog image cache has been cleaned on the Varnish servers.","Der Katalog Bilder Cache wurde in den Varnish Servern geleert."
30
+ "PageCache powered by Varnish settings","PageCache powered by Varnish Einstellungen"
31
+ "Varnish servers","Varnish Server"
32
+ "Purge category","Kategorie leeren"
33
+ "Purge categorie's cache item on save","Leere Cache-Element der Kategorie beim Speichern"
34
+ "Purge product","Produkt leeren"
35
+ "Purge product's cache item on save","Leere Cache-Element des Produkts beim Speichern"
36
+ "Purge CMS page","CMS-Seite leeren"
37
+ "Purge CMS page's cache item on save","Leere Cache-Element der CMS-Seite beim Speichern"
38
+ "Route","Route"
39
+ "TTL","TTL"
40
+ "Add route","Route hinzufügen"
41
+ "Varnish cache for ""%s"" has been purged.","Varnish Cache von ""%s"" wurde geleert."
42
+ "Varnish cache for the product's categories has been purged.","Varnish Cache der Produktkategorie wurde geleert."
app/locale/es_ES/Phoenix_VarnishCache.csv ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "All content types","Todos los tipos de contenido"
2
+ "All stores","Todas las tiendas"
3
+ "An error occurred while clearing the Varnish cache.","Ocurrió un error al vaciar Varnish Cache."
4
+ "CSS","CSS"
5
+ "Clean Varnish Cache","Vaciar Varnish Cache"
6
+ "Debug","Debug"
7
+ "Disable caching","Deshabilitar el almacenamiento en caché"
8
+ "Disable caching for routes","Deshabilitar el almacenamiento en caché para rutas"
9
+ "Disable caching vars","Deshabilitar el almacenamiento en caché de variable"
10
+ "Domain or IP list separted by semicolon (e.g. host1;127.0.0.1)","Lista de dominio o IP separada por punto y coma (por ejemplo,Lista de dominio o IP separada por punto y coma (por ejemplo host1;127.0.0.1)"
11
+ "Enable cache module","Habilitar el módulo de caché"
12
+ "HTML","HTML"
13
+ "If you see this message everything is fine.","Si ve este mensaje todo está bien."
14
+ "Images","Imágenes"
15
+ "JavaScript","JavaScript"
16
+ "PageCache powered by Varnish version: %s","PageCache powered by Varnish versión: %s"
17
+ "Pass X-headers for debugging purpose to the client and log purge requests to /var/log/varnish_cache.log (ensure developer log is enabled).","Pase HTTP X-encabezados para propósitos de depuraciónen al cliente y registre las solicitudes de purge en /var/log/varnish_cache.log (asegúrese de que el registro para desarrolladores está habilitado)."
18
+ "Port of the Varnish servers (e.g. 8080)","Puerto de los servidores de Varnish (por ejemplo 8080)"
19
+ "Remove selected cache items in external Varnish cache.","Quitar los elementos seleccionados de caché en la caché externa Varnish."
20
+ "Request variables that force setting of NO_CACHE cookie to permanent disable caching for visitor.","Variables de solicitud que asignan un NO_CACHE cookie para deshabilitar permanente el caché para el visitante."
21
+ "Server port","Puerto del servidor"
22
+ "Set ""no-cache"" HTTP header for certain routes/actions (e.g. checkout, catalog_product_view). Use one per line.","Asignar ""no-cache"" al encabezado HTTP para ciertas rutas o acciones (por ejemplo, checkout, catalog_product_view).Utilice uno por línea."
23
+ "Cache TTL for routes","Cache TTL for routes"
24
+ "Set a TTL of ""0"" for every request","Asignar un TTL de ""0"" para todas las solicitudes"
25
+ "TTL for cached pages in seconds (e.g. ""1800"" = page cache is valid for 30 minutes).","TTL para las páginas en caché en segundos (por ejemplo, ""1800"" =  page cache es válido por 30 minutos)."
26
+ "The JavaScript/CSS cache has been cleaned on the Varnish servers.","JavaScript / CSS caché se ha limpiado en los servidores de Varnish."
27
+ "The Varnish cache has been cleaned.","La caché de Varnish se ha limpiado."
28
+ "The catalog image cache has been cleaned on the Varnish servers.","El caché de imágenes de catálogo se ha limpiado en los servidores de Varnish."
29
+ "PageCache powered by Varnish settings","PageCache powered by Varnish configuración"
30
+ "Varnish servers","Servidores de Varnish"
31
+ "Purge category","Purgar categoría"
32
+ "Purge categorie's cache item on save","Purga elemento Categoría de la caché al guardar"
33
+ "Purge product","Purgar producto"
34
+ "Purge product's cache item on save","Purgar elemento Producto de la caché al guardar"
35
+ "Purge CMS page","Purgar página de CMS"
36
+ "Purge CMS page's cache item on save","Purgar elemento página de CMS de la caché al guardar"
37
+ "Route","Ruta"
38
+ "TTL","TTL"
39
+ "Add route","Añadir ruta"
40
+ "Varnish cache for ""%s"" has been purged.","La caché de Varnish de ""%s"" ha sido purgada."
41
+ "Varnish cache for the product's categories has been purged.","La caché de Varnish para las categorías del producto ha sido purgada."
app/locale/fr_FR/Phoenix_VarnishCache.csv ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "All content types","All content types"
2
+ "All stores","All stores"
3
+ "An error occurred while clearing the Varnish cache.","An error occurred while clearing the Varnish cache."
4
+ "CSS","CSS"
5
+ "Clean Varnish Cache","Clean Varnish Cache"
6
+ "Debug","Debug"
7
+ "Disable caching","Disable caching"
8
+ "Disable caching for routes","Disable caching for routes"
9
+ "Disable caching vars","Disable caching vars"
10
+ "Domain or IP list separted by semicolon (e.g. host1;127.0.0.1)","Domain or IP list separted by semicolon (e.g. host1;127.0.0.1)"
11
+ "Enable cache module","Enable cache module"
12
+ "HTML","HTML"
13
+ "If you see this message everything is fine.","If you see this message everything is fine."
14
+ "Images","Images"
15
+ "JavaScript","JavaScript"
16
+ "PageCache powered by Varnish version: %s","PageCache powered by Varnish version: %s"
17
+ "Pass X-headers for debugging purpose to the client and log purge requests to /var/log/varnish_cache.log (ensure developer log is enabled).","Pass X-headers for debugging purpose to the client and log purge requests to /var/log/varnish_cache.log (ensure developer log is enabled)."
18
+ "Port of the Varnish servers (e.g. 8080)","Port of the Varnish servers (e.g. 8080)"
19
+ "Remove selected cache items in external Varnish cache.","Remove selected cache items in external Varnish cache."
20
+ "Request variables that force setting of NO_CACHE cookie to permanent disable caching for visitor.","Request variables that force setting of NO_CACHE cookie to permanent disable caching for visitor."
21
+ "Server port","Server port"
22
+ "Set ""no-cache"" HTTP header for certain routes/actions (e.g. checkout, catalog_product_view). Use one per line.","Set ""no-cache"" HTTP header for certain routes/actions (e.g. checkout, catalog_product_view). Use one per line."
23
+ "Cache TTL for routes","Cache TTL for routes"
24
+ "Set a TTL of ""0"" for every request","Set un TTL ""0"" pour toutes les applications"
25
+ "TTL for cached pages in seconds for certain routes/actions (e.g. Route:""catalog_product_view"", TTL:""7200"").","TTL for cached pages in seconds for certain routes/actions (e.g. Route:""catalog_product_view"", TTL:""7200"")."
26
+ "The JavaScript/CSS cache has been cleaned on the Varnish servers.","The JavaScript/CSS cache has been cleaned on the Varnish servers."
27
+ "The Varnish cache has been cleaned.","The Varnish cache has been cleaned."
28
+ "The catalog image cache has been cleaned on the Varnish servers.","The catalog image cache has been cleaned on the Varnish servers."
29
+ "PageCache powered by Varnish settings","PageCache powered by Varnish settings"
30
+ "Varnish servers","Varnish servers"
31
+ "Purge category","Purger la catégorie"
32
+ "Purge categorie's cache item on save","Purger l'élément du cache categorie sur Enregistrer"
33
+ "Purge product","Purger produit"
34
+ "Purge product's cache item on save","Purger l'élément du cache de produits sur Enregistrer"
35
+ "Purge CMS page","Purger la page CMS"
36
+ "Purge CMS page's cache item on save","Élément du cache Purge CMS page sur Enregistrer"
37
+ "Route","Route"
38
+ "TTL","TTL"
39
+ "Add route","Ajouter un route"
40
+ "Varnish cache for ""%s"" has been purged.","Varnish cache pour ""%s"" a été purgé."
41
+ "Varnish cache for the product's categories has been purged.","Varnish cache pour les catégories de produit a été purgé."
app/locale/nb_NO/Phoenix_VarnishCache.csv ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "All content types","Alle typer innhold"
2
+ "All stores","Alle butikker"
3
+ "An error occurred while clearing the Varnish cache.","En feil oppstod under tømming av Varnish cache."
4
+ "CSS","CSS"
5
+ "Clean Varnish Cache","Tøm Varnish Cache"
6
+ "Debug","Debug"
7
+ "Disable caching","Deaktiver caching"
8
+ "Disable caching for routes","Deaktiver caching for ruter"
9
+ "Disable caching vars","Deaktiver caching vars"
10
+ "Domain or IP list separted by semicolon (e.g. host1;127.0.0.1)","Domene eller IP listen separert med semikolon (f.eks host1;127.0.0.1)"
11
+ "Enable cache module","Aktiver cache modulen"
12
+ "HTML","HTML"
13
+ "If you see this message everything is fine.","Hvis du ser denne meldingen er alt fint."
14
+ "Images","Bilder"
15
+ "JavaScript","JavaScript"
16
+ "PageCache powered by Varnish version: %s","PageCache powered by Varnish versjon: %s"
17
+ "Pass X-headers for debugging purpose to the client and log purge requests to /var/log/varnish_cache.log (ensure developer log is enabled).","Pass HTTP X-headere for debugging formål til klienten og logg purge forespørsler til /var/log/varnish_cache.log (husk å sikre at utvikleren loggen er aktivert)."
18
+ "Port of the Varnish servers (e.g. 8080)","Porten for Varnish-servere (f.eks. 8080)"
19
+ "Remove selected cache items in external Varnish cache.","Fjern valgte cache elementer i den eksterne Varnish cache."
20
+ "Request variables that force setting of NO_CACHE cookie to permanent disable caching for visitor.","Forerspørsel variabler som setter en NO_CACHE cookie for å  å deaktivere permanent caching for besøkende."
21
+ "Server port","Server port"
22
+ "Set ""no-cache"" HTTP header for certain routes/actions (e.g. checkout, catalog_product_view). Use one per line.","Sett ""no-cache"" på HTTP headere for enkelte ruter eller tiltak (f.eks checkout, catalog_product_view). Bruk én per linje.'","Asignar ""no-cache"" encabezado HTTP para ciertas rutas o acciones (por ejemplo, checkout, catalog_product_view).Utilice uno por línea.","Sett ""no-cache"" HTTP header for enkelte ruter eller tiltak (f.eks checkout, catalog_product_view). Bruk én per linje."
23
+ "Set a TTL of ""0"" for every request","Sett en TTL på ""0"" for hver forespørsel"
24
+ "Cache TTL for routes","Cache TTL for routes"
25
+ "TTL for cached pages in seconds (e.g. ""1800"" = page cache is valid for 30 minutes).","TTL for bufrede sider i sekunder (f.eks ""1800"" = sidecache er gyldig i 30 minutter).'","TTL para las páginas en caché en segundos (por ejemplo, ""1800"" =  caché de página válido por 30 minutos)."
26
+ "The JavaScript/CSS cache has been cleaned on the Varnish servers.","JavaScript/CSS cache har blitt tomt på Varnish servere."
27
+ "The Varnish cache has been cleaned.","Varnish cache har blitt tomt."
28
+ "The catalog image cache has been cleaned on the Varnish servers.","Katalog bilder cache har blitt tomt på Varnish servere."
29
+ "PageCache powered by Varnish settings","PageCache powered by Varnish innstillinger"
30
+ "Varnish servers","Varnish-servere"
31
+ "Purge category","Tomme kategorien"
32
+ "Purge categorie's cache item on save","Tøm Cache-Element kategori ved lagring"
33
+ "Purge product","Tøm produkt"
34
+ "Purge product's cache item on save","Tøm Cache-Element produkt ved lagring"
35
+ "Purge CMS page","Tøm CMS side"
36
+ "Purge CMS page's cache item on save","Tøm buffer element av CMS side ved lagring"
37
+ "Route","Rute"
38
+ "TTL","TTL"
39
+ "Add route","Legg rute"
40
+ "Varnish cache for ""%s"" has been purged.","Varnish cache for "% s" har blitt tømt."
41
+ "Varnish cache for the product's categories has been purged.","Varnish cache av produktets kategorier har blitt tømt."
package.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Varnish_Cache</name>
4
+ <version>3.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Certified module to integrate Magento and Varnish that makes your eCommerce site fly</summary>
10
+ <description>&lt;p&gt;&lt;span&gt;Make your Magento store fly - with transparently integrated &lt;a href="http://www.varnish-cache.org"&gt;Varnish Cache&lt;/a&gt;! Blazing fast response times and lower server load during peak times making your Magento store 100x faster.&lt;/span&gt;&lt;/p&gt;&#xD;
11
+ &lt;p&gt;&lt;span&gt;The PageCache module allows you to control your Varnish Cache instance from the Magento backend to trigger purge requests for single stores or content types. It also prevents caching of store pages containing customer information like shopping carts or logins.&lt;/span&gt;&lt;/p&gt;&#xD;
12
+ &lt;p&gt;&lt;span&gt;No more worries about huge marketing campaigns or maniac crawlers: Varnish Cache will mitigate any peaks so your Magento store can care about the buyers and transactions!&lt;/span&gt;&lt;/p&gt;&#xD;
13
+ &lt;p&gt;&lt;strong&gt;The PageCache module has been&#xA0;architectural certified&#xA0;by Varnish Software to ensure highest quality and reliability for Magento stores.&lt;/strong&gt;&lt;/p&gt;&#xD;
14
+ &lt;p&gt;&#xA0;&lt;/p&gt;&#xD;
15
+ &lt;p&gt;&lt;strong&gt;Features:&lt;/strong&gt;&lt;/p&gt;&#xD;
16
+ &lt;p&gt;- Allows &lt;strong&gt;full page caching&lt;/strong&gt; of Magento store frontends with &lt;a href="http://www.varnish-cache.org" target="_blank"&gt;Varnish&lt;/a&gt;&lt;br /&gt;- Prevent caching of pages containing custom information (shopping carts, logins)&lt;br /&gt;- Configure request paths (controller, action) to be excluded from caching&lt;br /&gt;- Clean caches for single store views or content types&lt;br /&gt;- Maintain several Varnish instances&#xA0;from the Magento backend&lt;br /&gt;- Set TTL for content pages per store view&lt;br /&gt;- Deactivate Varnish cache for single store views or websites&lt;br /&gt;- Easily deactivate caching for certain Magento modules&lt;br /&gt;- Enable debug mode to analyse any issues&lt;br /&gt;&lt;strong&gt;- Ready to go Varnish configuration file (VCL)&lt;/strong&gt;&lt;/p&gt;</description>
17
+ <notes>- Changed license to OSL for Community Edition&#xD;
18
+ - Instantly purge cache items of CMS pages, categories and products on save&#xD;
19
+ - Configure different TTLs per route/controller&#xD;
20
+ - Use "Cache-Control:s-maxage=x" instead of propriatary headers to control Varnish&#xD;
21
+ - Improved Magento EE compatibility&#xD;
22
+ - Allow frontend Varnish caching while beeing logged in the backend&#xD;
23
+ - Added design exceptions (beta)</notes>
24
+ <authors><author><name>PHOENIX</name><user>auto-converted</user><email>kraus@phoenix-medien.de</email></author></authors>
25
+ <date>2011-11-14</date>
26
+ <time>08:45:06</time>
27
+ <contents><target name="magecommunity"><dir name="Phoenix"><dir name="VarnishCache"><dir name="Block"><dir name="Adminhtml"><dir name="Cache"><file name="Additional.php" hash="2b846bf516edccf6f3f32d5f272a4438"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="RouteTTL.php" hash="f8e78d9f5324f7d7cd6cb4440e487254"/><file name="Versioninfo.php" hash="b259124a7ac3fe0a9df98599aca4ee59"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Helper"><dir name="Control"><dir name="Catalog"><file name="Category.php" hash="ab5c42db3dfcf9284c1ee8af54431376"/><file name="Product.php" hash="5d23dc87df1c31ecc39bf8acff49b36a"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Cms"><file name="Page.php" hash="691c45fab825d6dbdd3ff22167de1952"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="Cache.php" hash="c91379daeaae1486bf88d01ed4e37e39"/><file name="Data.php" hash="1a9ecd2bedba96b3ea54e4ad6712fb3f"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Model"><dir name="Catalog"><dir name="Category"><file name="Product.php" hash="995f58362194d2fe5c432dd02e2d9691"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Product"><file name="Relation.php" hash="904a87fd513bed6c3361ba9b072b5d50"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Cms"><dir name="Page"><file name="Store.php" hash="ad6181591bf41868c8cdfa3ade83ac5f"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Control"><dir name="Catalog"><file name="Category.php" hash="28abba14957be0db960cdf28be4101a0"/><file name="Product.php" hash="c2d0e89f46ac83c638d0e46fbb8ba388"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Cms"><file name="Page.php" hash="397f5867e0e0454fc39d01b12b9ce88d"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="Abstract.php" hash="e9dcf88ec8f8c9c59f69af1379be0ef1"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Resource"><dir name="Mysql4"><dir name="Catalog"><dir name="Category"><dir name="Product"><file name="Collection.php" hash="de278cceafcad54779fcddded7815ebd"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="Product.php" hash="4583fc0ae57e6af3020dadfc49d1b7c7"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Product"><dir name="Relation"><file name="Collection.php" hash="b1e9bb5b00f3b14bebd716723a2975c9"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Cms"><dir name="Page"><dir name="Store"><file name="Collection.php" hash="8d083ad449b9cb8c2763fb61a57dd4ec"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="Store.php" hash="3e26bfe2ead97fdc9d6b7cc4ed5423f2"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Core"><dir name="Url"><dir name="Rewrite"><file name="Collection.php" hash="0890e77bf5afbe4d049edf3d7d7e308f"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="Control.php" hash="8877d200d5fd8e3980298b04d1e66456"/><file name="Observer.php" hash="36c5b769721f3ffbd208b064be316f2b"/><file name="Processor.php" hash="7cea33d8a591c54e7e7c4e68781f3d08"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="VarnishCacheController.php" hash="d4824e24de545f8de6d504fb8fadc3e6"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="etc"><file name="config.xml" hash="a6dfed6e655f569cd034599e1edef44f"/><file name="default_2.1.vcl" hash="7778c9021a5b89503e37b23f1315d6f3"/><file name="default_3.0.vcl" hash="f72645c1eb3940982ccb3d77bf5ca7dd"/><file name="system.xml" hash="3af9182a9635a2def4d323dac181b1da"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Phoenix_VarnishCache.csv" hash="b8ee686f2adf93bbefa3475cf52be0be"/></dir><dir name="en_US"><file name="Phoenix_Ipayment.csv" hash=""/></dir><dir name="es_ES"><file name="Phoenix_VarnishCache.csv" hash="83116dfb6997c68dcaefddf2ad32c9d8"/></dir><dir name="fr_FR"><file name="Phoenix_VarnishCache.csv" hash="2e491cb08a5685599692e84d3c79e29f"/></dir><dir name="nb_NO"><file name="Phoenix_VarnishCache.csv" hash="2853eafaac256faf098cbdfa727be8e6"/></dir></target><target name="mageetc"><dir name="modules"><file name="Phoenix_VarnishCache.xml" hash="273157270c3f6568c76be647ecbf7e11"/></dir><dir name="."><file name="varnishcache.xml" hash="91bb9dfbb4299736371d3b4b45adee7a"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="varnishcache"><dir name="cache"><file name="additional.phtml" hash="20a327558440bb77b4a2246a34db4aa0"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir><dir name="layout"><file name="varnishcache.xml" hash="89b14f64884cabe579efcb790f0e62d0"/></dir></dir></dir></dir></target><target name="mage"><dir name="."><file name="README_VARNISH_CACHE.txt" hash="6bd38578c6599564cdb485de38029391"/></dir></target></contents>
28
+ <compatible/>
29
+ <dependencies/>
30
+ </package>