Version Notes
Supports Magento v1.6 and later
Download this release
Release Info
Developer | Chris Wells |
Extension | Nexcessnet_Turpentine |
Version | 0.7.3 |
Comparing to | |
See all releases |
Code changes from version 0.7.2 to 0.7.3
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php +1 -1
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +22 -3
- app/code/community/Nexcessnet/Turpentine/etc/config.xml +1 -1
- app/code/community/Nexcessnet/Turpentine/etc/config.xml~ +547 -0
- app/code/community/Nexcessnet/Turpentine/etc/system.xml +10 -0
- app/code/community/Nexcessnet/Turpentine/misc/version-2.vcl +3 -1
- app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl +3 -1
- app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +5 -1
- app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl~ +483 -0
- package.xml +1 -1
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php
CHANGED
@@ -104,7 +104,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin {
|
|
104 |
$result[$socketName] = 'Failed to load configurator';
|
105 |
} else {
|
106 |
$vcl = $cfgr->generate($helper->shouldStripVclWhitespace('apply'));
|
107 |
-
$vclName = Mage::helper('turpentine/data')
|
108 |
->secureHash(microtime());
|
109 |
try {
|
110 |
$this->_testEsiSyntaxParam($socket);
|
104 |
$result[$socketName] = 'Failed to load configurator';
|
105 |
} else {
|
106 |
$vcl = $cfgr->generate($helper->shouldStripVclWhitespace('apply'));
|
107 |
+
$vclName = 'vcl_' . Mage::helper('turpentine/data')
|
108 |
->secureHash(microtime());
|
109 |
try {
|
110 |
$this->_testEsiSyntaxParam($socket);
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php
CHANGED
@@ -684,7 +684,7 @@ EOS;
|
|
684 |
$parts = explode(':', $backendNode, 2);
|
685 |
$host = (empty($parts[0])) ? '127.0.0.1' : $parts[0];
|
686 |
$port = (empty($parts[1])) ? '80' : $parts[1];
|
687 |
-
$backends .= $this->_vcl_director_backend($host, $port, $probeUrl, $backendOptions);
|
688 |
}
|
689 |
$vars = array(
|
690 |
'name' => $name,
|
@@ -698,14 +698,15 @@ EOS;
|
|
698 |
*
|
699 |
* @param string $host backend host
|
700 |
* @param string $port backend port
|
|
|
701 |
* @param string $probeUrl URL to check if backend is up
|
702 |
* @param array $options extra options for backend
|
703 |
* @return string
|
704 |
*/
|
705 |
-
protected function _vcl_director_backend($host, $port, $probeUrl = '', $options = array()) {
|
706 |
$tpl = <<<EOS
|
707 |
{
|
708 |
-
.backend = {
|
709 |
.host = "{{host}}";
|
710 |
.port = "{{port}}";
|
711 |
{{probe}}
|
@@ -901,6 +902,20 @@ EOS;
|
|
901 |
'debug_ips' => Mage::getStoreConfig('dev/restrict/allow_ips') ));
|
902 |
}
|
903 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
904 |
/**
|
905 |
* When using Varnish as front door listen on port 80 and Nginx/Apache listen on port 443 for HTTPS, the fix will keep the url parameters when redirect from HTTP to HTTPS.
|
906 |
*
|
@@ -1085,6 +1100,10 @@ sub vcl_synth {
|
|
1085 |
// set the vcl_error from Magento database
|
1086 |
$vars['vcl_synth'] = $this->_vcl_sub_synth();
|
1087 |
}
|
|
|
|
|
|
|
|
|
1088 |
|
1089 |
if (Mage::getStoreConfig('turpentine_varnish/general/https_redirect_fix')) {
|
1090 |
$vars['https_redirect'] = $this->_vcl_sub_https_redirect_fix();
|
684 |
$parts = explode(':', $backendNode, 2);
|
685 |
$host = (empty($parts[0])) ? '127.0.0.1' : $parts[0];
|
686 |
$port = (empty($parts[1])) ? '80' : $parts[1];
|
687 |
+
$backends .= $this->_vcl_director_backend($host, $port, $prefix.$number, $probeUrl, $backendOptions);
|
688 |
}
|
689 |
$vars = array(
|
690 |
'name' => $name,
|
698 |
*
|
699 |
* @param string $host backend host
|
700 |
* @param string $port backend port
|
701 |
+
* @param string $descriptor backend descriptor
|
702 |
* @param string $probeUrl URL to check if backend is up
|
703 |
* @param array $options extra options for backend
|
704 |
* @return string
|
705 |
*/
|
706 |
+
protected function _vcl_director_backend($host, $port, $descriptor = '', $probeUrl = '', $options = array()) {
|
707 |
$tpl = <<<EOS
|
708 |
{
|
709 |
+
.backend {$descriptor} = {
|
710 |
.host = "{{host}}";
|
711 |
.port = "{{port}}";
|
712 |
{{probe}}
|
902 |
'debug_ips' => Mage::getStoreConfig('dev/restrict/allow_ips') ));
|
903 |
}
|
904 |
|
905 |
+
/**
|
906 |
+
* When using Varnish on port 80 and Hitch listen on port 443 for HTTPS, the fix will set X-Forwarded-Proto to HTTPS to prevent redirect loop.
|
907 |
+
*
|
908 |
+
* @return string
|
909 |
+
*/
|
910 |
+
protected function _vcl_sub_https_proto_fix() {
|
911 |
+
$tpl = <<<EOS
|
912 |
+
if (std.port(server.ip) == 443) {
|
913 |
+
set req.http.X-Forwarded-Proto = "https";
|
914 |
+
}
|
915 |
+
EOS;
|
916 |
+
return $tpl;
|
917 |
+
}
|
918 |
+
|
919 |
/**
|
920 |
* When using Varnish as front door listen on port 80 and Nginx/Apache listen on port 443 for HTTPS, the fix will keep the url parameters when redirect from HTTP to HTTPS.
|
921 |
*
|
1100 |
// set the vcl_error from Magento database
|
1101 |
$vars['vcl_synth'] = $this->_vcl_sub_synth();
|
1102 |
}
|
1103 |
+
|
1104 |
+
if (Mage::getStoreConfig('turpentine_varnish/general/https_proto_fix')) {
|
1105 |
+
$vars['https_proto_fix'] = $this->_vcl_sub_https_proto_fix();
|
1106 |
+
}
|
1107 |
|
1108 |
if (Mage::getStoreConfig('turpentine_varnish/general/https_redirect_fix')) {
|
1109 |
$vars['https_redirect'] = $this->_vcl_sub_https_redirect_fix();
|
app/code/community/Nexcessnet/Turpentine/etc/config.xml
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
-
<version>0.7.
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
+
<version>0.7.3</version>
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
app/code/community/Nexcessnet/Turpentine/etc/config.xml~
ADDED
@@ -0,0 +1,547 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
Nexcess.net Turpentine Extension for Magento
|
4 |
+
Copyright (C) 2012 Nexcess.net L.L.C.
|
5 |
+
|
6 |
+
This program is free software; you can redistribute it and/or modify
|
7 |
+
it under the terms of the GNU General Public License as published by
|
8 |
+
the Free Software Foundation; either version 2 of the License, or
|
9 |
+
(at your option) any later version.
|
10 |
+
|
11 |
+
This program is distributed in the hope that it will be useful,
|
12 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
GNU General Public License for more details.
|
15 |
+
|
16 |
+
You should have received a copy of the GNU General Public License along
|
17 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
18 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
19 |
+
-->
|
20 |
+
<config>
|
21 |
+
<modules>
|
22 |
+
<Nexcessnet_Turpentine>
|
23 |
+
<version>0.7.0</version>
|
24 |
+
</Nexcessnet_Turpentine>
|
25 |
+
</modules>
|
26 |
+
<default>
|
27 |
+
<turpentine_varnish>
|
28 |
+
<general>
|
29 |
+
<auto_apply_on_save>1</auto_apply_on_save>
|
30 |
+
<strip_vcl_whitespace>always</strip_vcl_whitespace>
|
31 |
+
<varnish_debug>0</varnish_debug>
|
32 |
+
<vcl_fix>1</vcl_fix>
|
33 |
+
<block_debug>0</block_debug>
|
34 |
+
<ajax_messages>1</ajax_messages>
|
35 |
+
<fix_product_toolbar>0</fix_product_toolbar>
|
36 |
+
<crawler_enable>0</crawler_enable>
|
37 |
+
<crawler_debug>0</crawler_debug>
|
38 |
+
<crawler_batchsize>0</crawler_batchsize>
|
39 |
+
<crawler_batchwait>0</crawler_batchwait>
|
40 |
+
</general>
|
41 |
+
<logging>
|
42 |
+
<use_custom_log_file>0</use_custom_log_file>
|
43 |
+
<custom_log_file_name>turpentine.log</custom_log_file_name>
|
44 |
+
</logging>
|
45 |
+
<servers>
|
46 |
+
<version>auto</version>
|
47 |
+
<server_list>127.0.0.1:6082</server_list>
|
48 |
+
<config_file>{{root_dir}}/var/default.vcl</config_file>
|
49 |
+
<custom_include_file>{{root_dir}}/app/code/community/Nexcessnet/Turpentine/misc/custom_include.vcl</custom_include_file>
|
50 |
+
<custom_include_file_top>{{root_dir}}/app/code/community/Nexcessnet/Turpentine/misc/custom_include_top.vcl</custom_include_file_top>
|
51 |
+
<custom_vcl_template></custom_vcl_template>
|
52 |
+
</servers>
|
53 |
+
</turpentine_varnish>
|
54 |
+
<turpentine_vcl>
|
55 |
+
<backend>
|
56 |
+
<load_balancing>no</load_balancing>
|
57 |
+
<backend_host>127.0.0.1</backend_host>
|
58 |
+
<backend_port>8080</backend_port>
|
59 |
+
<backend_nodes>127.0.0.1:8080</backend_nodes>
|
60 |
+
<backend_probe_url/>
|
61 |
+
<backend_nodes_admin>127.0.0.1:8080</backend_nodes_admin>
|
62 |
+
<backend_probe_url_admin/>
|
63 |
+
<frontend_timeout>300</frontend_timeout>
|
64 |
+
<admin_timeout>21600</admin_timeout>
|
65 |
+
<crawlers>127.0.0.1</crawlers>
|
66 |
+
<crawler_user_agents><![CDATA[ApacheBench/.*,.*Googlebot.*,JoeDog/.*,.*Siege/.*,magespeedtest\.com,Nexcessnet_Turpentine/.*,.*PTST.*]]></crawler_user_agents>
|
67 |
+
</backend>
|
68 |
+
<normalization>
|
69 |
+
<encoding>1</encoding>
|
70 |
+
<user_agent>0</user_agent>
|
71 |
+
<host>0</host>
|
72 |
+
</normalization>
|
73 |
+
<ttls>
|
74 |
+
<grace_period>15</grace_period>
|
75 |
+
<default_ttl>3600</default_ttl>
|
76 |
+
<static_ttl>28800</static_ttl>
|
77 |
+
<!--
|
78 |
+
<lru_factor>15</lru_factor>
|
79 |
+
-->
|
80 |
+
</ttls>
|
81 |
+
<urls>
|
82 |
+
<url_blacklist><![CDATA[cron\.php]]></url_blacklist>
|
83 |
+
</urls>
|
84 |
+
<params>
|
85 |
+
<get_params>__SID,XDEBUG_PROFILE</get_params>
|
86 |
+
<ignore_get_params>utm_source,utm_medium,utm_campaign,utm_content,utm_term,gclid,cx,ie,cof,siteurl</ignore_get_params>
|
87 |
+
<transfer_unmodified_url>0</transfer_unmodified_url>
|
88 |
+
</params>
|
89 |
+
<static>
|
90 |
+
<force_static>1</force_static>
|
91 |
+
<exts>css,js,jpe?g,png,gif,ico,swf</exts>
|
92 |
+
<simple_hash>1</simple_hash>
|
93 |
+
</static>
|
94 |
+
</turpentine_vcl>
|
95 |
+
</default>
|
96 |
+
<global>
|
97 |
+
<!--
|
98 |
+
This disables Magento visitor logging for Turpentine ESI
|
99 |
+
requests. The logging was pointless and caused AJAX blocks to
|
100 |
+
take much more time then they otherwise would to load (most of
|
101 |
+
the time was spent doing database writes)
|
102 |
+
-->
|
103 |
+
<!-- Disabled because if the visitor doesn't have any entries in the
|
104 |
+
visitor log the product comparison block won't work for non-logged-in
|
105 |
+
visitors.
|
106 |
+
@see Mage/Catalog/controllers/Product/CompareController.php#79
|
107 |
+
|
108 |
+
<ignoredModules>
|
109 |
+
<entities>
|
110 |
+
<turpentine/>
|
111 |
+
</entities>
|
112 |
+
</ignoredModules>
|
113 |
+
-->
|
114 |
+
<blocks>
|
115 |
+
<turpentine>
|
116 |
+
<class>Nexcessnet_Turpentine_Block</class>
|
117 |
+
</turpentine>
|
118 |
+
<!--
|
119 |
+
The core/messages block is rewritten because it doesn't use a
|
120 |
+
template we can replace with an ESI include tag, just dumps out a
|
121 |
+
block of hard-coded HTML and also frequently skips the toHtml method
|
122 |
+
|
123 |
+
However, since class rewrites aren't conditional and we only want to
|
124 |
+
do this rewrite if the Enable Flash Messages option is enabled the
|
125 |
+
rewrite is actually added at runtime (controller_front_init_before),
|
126 |
+
see observer_esi::addMessagesBlockRewrite . Leaving this rewrite
|
127 |
+
here but commented out for clarity
|
128 |
+
-->
|
129 |
+
<!--
|
130 |
+
<core>
|
131 |
+
<rewrite>
|
132 |
+
<messages>Nexcessnet_Turpentine_Block_Core_Messages</messages>
|
133 |
+
</rewrite>
|
134 |
+
</core>
|
135 |
+
-->
|
136 |
+
<!--
|
137 |
+
Rewrite the poll ActivePoll block, as it uses its own custom
|
138 |
+
template setting methods.
|
139 |
+
-->
|
140 |
+
<poll>
|
141 |
+
<rewrite>
|
142 |
+
<activePoll>Nexcessnet_Turpentine_Block_Poll_ActivePoll</activePoll>
|
143 |
+
</rewrite>
|
144 |
+
</poll>
|
145 |
+
|
146 |
+
<!--
|
147 |
+
Rewrite the compared and viewed product block. Default behavior returns '' if
|
148 |
+
no items to display, which prevents display of the ESI url, causing caching problems
|
149 |
+
-->
|
150 |
+
<reports>
|
151 |
+
<rewrite>
|
152 |
+
<product_compared>Nexcessnet_Turpentine_Block_Product_Compared</product_compared>
|
153 |
+
<product_viewed>Nexcessnet_Turpentine_Block_Product_Viewed</product_viewed>
|
154 |
+
</rewrite>
|
155 |
+
</reports>
|
156 |
+
|
157 |
+
<adminhtml>
|
158 |
+
<rewrite>
|
159 |
+
<cache_grid>Nexcessnet_Turpentine_Block_Adminhtml_Cache_Grid</cache_grid>
|
160 |
+
</rewrite>
|
161 |
+
</adminhtml>
|
162 |
+
</blocks>
|
163 |
+
<helpers>
|
164 |
+
<turpentine>
|
165 |
+
<class>Nexcessnet_Turpentine_Helper</class>
|
166 |
+
</turpentine>
|
167 |
+
</helpers>
|
168 |
+
<models>
|
169 |
+
<turpentine>
|
170 |
+
<class>Nexcessnet_Turpentine_Model</class>
|
171 |
+
</turpentine>
|
172 |
+
<core>
|
173 |
+
<rewrite>
|
174 |
+
<session>Nexcessnet_Turpentine_Model_Core_Session</session>
|
175 |
+
</rewrite>
|
176 |
+
</core>
|
177 |
+
</models>
|
178 |
+
<cache>
|
179 |
+
<types>
|
180 |
+
<!--
|
181 |
+
These aren't used to actually store anything in Magento's cache,
|
182 |
+
we just use them to signal Varnish to purge it's cache. Note
|
183 |
+
that the type names must match the MAGE_CACHE_NAME constant in
|
184 |
+
the Varnish and ESI helpers.
|
185 |
+
-->
|
186 |
+
<turpentine_pages>
|
187 |
+
<label>Varnish Pages</label>
|
188 |
+
<description>Full pages cached in Varnish (will also flush ESI blocks)</description>
|
189 |
+
<tags>TURPENTINE_FAKE_PAGE_TAG</tags>
|
190 |
+
</turpentine_pages>
|
191 |
+
<turpentine_esi_blocks>
|
192 |
+
<label>Varnish ESI Blocks</label>
|
193 |
+
<description>ESI blocks cached in Varnish (this should not be disabled except for debugging)</description>
|
194 |
+
<!--
|
195 |
+
This is helpful to prevent blocks from being double ESI-
|
196 |
+
included, which ends up resulting in the "ESI processing
|
197 |
+
not enabled" error
|
198 |
+
-->
|
199 |
+
<tags>BLOCK_HTML</tags>
|
200 |
+
</turpentine_esi_blocks>
|
201 |
+
</types>
|
202 |
+
</cache>
|
203 |
+
<events>
|
204 |
+
<!-- Varnish Events -->
|
205 |
+
<http_response_send_before>
|
206 |
+
<observers>
|
207 |
+
<turpentine_varnish_http_response_send_before>
|
208 |
+
<class>turpentine/observer_varnish</class>
|
209 |
+
<method>setCacheFlagHeader</method>
|
210 |
+
</turpentine_varnish_http_response_send_before>
|
211 |
+
</observers>
|
212 |
+
</http_response_send_before>
|
213 |
+
|
214 |
+
<admin_system_config_changed_section_turpentine_varnish>
|
215 |
+
<observers>
|
216 |
+
<turpentine_varnish_admin_system_config_changed_section_turpentine_varnish>
|
217 |
+
<class>turpentine/observer_varnish</class>
|
218 |
+
<method>adminSystemConfigChangedSection</method>
|
219 |
+
</turpentine_varnish_admin_system_config_changed_section_turpentine_varnish>
|
220 |
+
</observers>
|
221 |
+
</admin_system_config_changed_section_turpentine_varnish>
|
222 |
+
<admin_system_config_changed_section_turpentine_vcl>
|
223 |
+
<observers>
|
224 |
+
<turpentine_varnish_admin_system_config_changed_section_turpentine_vcl>
|
225 |
+
<class>turpentine/observer_varnish</class>
|
226 |
+
<method>adminSystemConfigChangedSection</method>
|
227 |
+
</turpentine_varnish_admin_system_config_changed_section_turpentine_vcl>
|
228 |
+
</observers>
|
229 |
+
</admin_system_config_changed_section_turpentine_vcl>
|
230 |
+
|
231 |
+
<!-- ESI Events -->
|
232 |
+
<core_block_abstract_to_html_before>
|
233 |
+
<observers>
|
234 |
+
<turpentine_esi_core_block_abstract_to_html_before>
|
235 |
+
<type>singleton</type>
|
236 |
+
<class>turpentine/observer_esi</class>
|
237 |
+
<method>injectEsi</method>
|
238 |
+
</turpentine_esi_core_block_abstract_to_html_before>
|
239 |
+
</observers>
|
240 |
+
</core_block_abstract_to_html_before>
|
241 |
+
<http_response_send_before>
|
242 |
+
<observers>
|
243 |
+
<turpentine_esi_http_response_send_before>
|
244 |
+
<class>turpentine/observer_esi</class>
|
245 |
+
<method>setFlagHeaders</method>
|
246 |
+
</turpentine_esi_http_response_send_before>
|
247 |
+
<turpentine_esi_replace_form_key_placeholder>
|
248 |
+
<class>turpentine/observer_esi</class>
|
249 |
+
<method>replaceFormKeyPlaceholder</method>
|
250 |
+
</turpentine_esi_replace_form_key_placeholder>
|
251 |
+
</observers>
|
252 |
+
</http_response_send_before>
|
253 |
+
<controller_action_layout_generate_blocks_after>
|
254 |
+
<observers>
|
255 |
+
<turpentine_esi_controller_action_layout_generate_blocks_after>
|
256 |
+
<class>turpentine/observer_esi</class>
|
257 |
+
<method>checkCacheFlag</method>
|
258 |
+
</turpentine_esi_controller_action_layout_generate_blocks_after>
|
259 |
+
</observers>
|
260 |
+
</controller_action_layout_generate_blocks_after>
|
261 |
+
<customer_login>
|
262 |
+
<observers>
|
263 |
+
<turpentine_customer_login_cookie>
|
264 |
+
<class>turpentine/observer_esi</class>
|
265 |
+
<method>setCustomerGroupCookie</method>
|
266 |
+
</turpentine_customer_login_cookie>
|
267 |
+
</observers>
|
268 |
+
</customer_login>
|
269 |
+
<customer_logout>
|
270 |
+
<observers>
|
271 |
+
<turpentine_customer_logout_remove_cookie>
|
272 |
+
<class>turpentine/observer_esi</class>
|
273 |
+
<method>removeCustomerGroupCookie</method>
|
274 |
+
</turpentine_customer_logout_remove_cookie>
|
275 |
+
</observers>
|
276 |
+
</customer_logout>
|
277 |
+
<!--
|
278 |
+
Magento sometimes sees the last URL as being the
|
279 |
+
turpentine/esi/getBlock url, and then redirects to it which is not
|
280 |
+
good. We need to check and intercept it if it happens
|
281 |
+
-->
|
282 |
+
<controller_response_redirect>
|
283 |
+
<observers>
|
284 |
+
<turpentine_esi_controller_response_redirect>
|
285 |
+
<class>turpentine/observer_esi</class>
|
286 |
+
<method>checkRedirectUrl</method>
|
287 |
+
</turpentine_esi_controller_response_redirect>
|
288 |
+
</observers>
|
289 |
+
</controller_response_redirect>
|
290 |
+
|
291 |
+
<!--
|
292 |
+
Load the ESI client cache clear events from stored config at
|
293 |
+
runtime
|
294 |
+
-->
|
295 |
+
<controller_front_init_before>
|
296 |
+
<observers>
|
297 |
+
<turpentine_esi_controller_front_init_before>
|
298 |
+
<class>turpentine/observer_esi</class>
|
299 |
+
<method>loadCacheClearEvents</method>
|
300 |
+
</turpentine_esi_controller_front_init_before>
|
301 |
+
<turpentine_esi_controller_front_init_before2>
|
302 |
+
<class>turpentine/observer_esi</class>
|
303 |
+
<method>addMessagesBlockRewrite</method>
|
304 |
+
</turpentine_esi_controller_front_init_before2>
|
305 |
+
<turpentine_varnish_controller_front_init_before>
|
306 |
+
<class>turpentine/observer_varnish</class>
|
307 |
+
<method>addProductListToolbarRewrite</method>
|
308 |
+
</turpentine_varnish_controller_front_init_before>
|
309 |
+
<turpentine_varnish_fix_cm_redissession_locks>
|
310 |
+
<class>turpentine/observer_varnish</class>
|
311 |
+
<method>fixCmRedisSessionLocks</method>
|
312 |
+
</turpentine_varnish_fix_cm_redissession_locks>
|
313 |
+
<turpentine_esi_set_replace_form_key_flag>
|
314 |
+
<class>turpentine/observer_esi</class>
|
315 |
+
<method>setReplaceFormKeyFlag</method>
|
316 |
+
</turpentine_esi_set_replace_form_key_flag>
|
317 |
+
</observers>
|
318 |
+
</controller_front_init_before>
|
319 |
+
|
320 |
+
<!-- Varnish cache clear events -->
|
321 |
+
<catalog_product_save_commit_after>
|
322 |
+
<observers>
|
323 |
+
<turpentine_varnish_catalog_product_save_commit_after>
|
324 |
+
<class>turpentine/observer_ban</class>
|
325 |
+
<method>banProductPageCache</method>
|
326 |
+
</turpentine_varnish_catalog_product_save_commit_after>
|
327 |
+
</observers>
|
328 |
+
</catalog_product_save_commit_after>
|
329 |
+
<review_save_after>
|
330 |
+
<observers>
|
331 |
+
<turpentine_varnish_review_save_after>
|
332 |
+
<class>turpentine/observer_ban</class>
|
333 |
+
<method>banProductReview</method>
|
334 |
+
</turpentine_varnish_review_save_after>
|
335 |
+
</observers>
|
336 |
+
</review_save_after>
|
337 |
+
<cataloginventory_stock_item_save_after>
|
338 |
+
<observers>
|
339 |
+
<turpentine_varnish_cataloginventory_stock_item_save_after>
|
340 |
+
<class>turpentine/observer_ban</class>
|
341 |
+
<method>banProductPageCacheCheckStock</method>
|
342 |
+
</turpentine_varnish_cataloginventory_stock_item_save_after>
|
343 |
+
</observers>
|
344 |
+
</cataloginventory_stock_item_save_after>
|
345 |
+
<catalog_category_save_commit_after>
|
346 |
+
<observers>
|
347 |
+
<turpentine_varnish_catalog_category_save_commit_after>
|
348 |
+
<class>turpentine/observer_ban</class>
|
349 |
+
<method>banCategoryCache</method>
|
350 |
+
</turpentine_varnish_catalog_category_save_commit_after>
|
351 |
+
</observers>
|
352 |
+
</catalog_category_save_commit_after>
|
353 |
+
<!--
|
354 |
+
This is disabled because it causes broken images on cached pages
|
355 |
+
-->
|
356 |
+
<!--
|
357 |
+
<clean_media_cache_after>
|
358 |
+
<observers>
|
359 |
+
<turpentine_varnish_clean_media_cache_after>
|
360 |
+
<class>turpentine/observer_ban</class>
|
361 |
+
<method>banMediaCache</method>
|
362 |
+
</turpentine_varnish_clean_media_cache_after>
|
363 |
+
</observers>
|
364 |
+
</clean_media_cache_after>
|
365 |
+
<clean_catalog_images_cache_after>
|
366 |
+
<observers>
|
367 |
+
<turpentine_varnish_clean_catalog_images_cache_after>
|
368 |
+
<class>turpentine/observer_ban</class>
|
369 |
+
<method>banCatalogImagesCache</method>
|
370 |
+
</turpentine_varnish_clean_catalog_images_cache_after>
|
371 |
+
</observers>
|
372 |
+
</clean_catalog_images_cache_after>
|
373 |
+
-->
|
374 |
+
<cms_page_save_commit_after>
|
375 |
+
<observers>
|
376 |
+
<turpentine_varnish_cms_page_save_commit_after>
|
377 |
+
<class>turpentine/observer_ban</class>
|
378 |
+
<method>banCmsPageCache</method>
|
379 |
+
</turpentine_varnish_cms_page_save_commit_after>
|
380 |
+
</observers>
|
381 |
+
</cms_page_save_commit_after>
|
382 |
+
<enterprise_cms_revision_save_commit_after>
|
383 |
+
<observers>
|
384 |
+
<turpentine_varnish_enterprise_cms_revision_save_commit_after>
|
385 |
+
<class>turpentine/observer_ban</class>
|
386 |
+
<method>banCmsPageRevisionCache</method>
|
387 |
+
<type>singleton</type>
|
388 |
+
</turpentine_varnish_enterprise_cms_revision_save_commit_after>
|
389 |
+
</observers>
|
390 |
+
</enterprise_cms_revision_save_commit_after>
|
391 |
+
<adminhtml_cache_flush_system>
|
392 |
+
<observers>
|
393 |
+
<turpentine_varnish_adminhtml_cache_flush_system>
|
394 |
+
<class>turpentine/observer_ban</class>
|
395 |
+
<method>banAllCache</method>
|
396 |
+
</turpentine_varnish_adminhtml_cache_flush_system>
|
397 |
+
</observers>
|
398 |
+
</adminhtml_cache_flush_system>
|
399 |
+
<adminhtml_cache_flush_all>
|
400 |
+
<observers>
|
401 |
+
<turpentine_varnish_adminhtml_cache_flush_all>
|
402 |
+
<class>turpentine/observer_ban</class>
|
403 |
+
<method>banAllCache</method>
|
404 |
+
</turpentine_varnish_adminhtml_cache_flush_all>
|
405 |
+
</observers>
|
406 |
+
</adminhtml_cache_flush_all>
|
407 |
+
<adminhtml_cache_refresh_type>
|
408 |
+
<observers>
|
409 |
+
<turpentine_varnish_adminhtml_cache_refresh_type>
|
410 |
+
<class>turpentine/observer_ban</class>
|
411 |
+
<method>banCacheType</method>
|
412 |
+
</turpentine_varnish_adminhtml_cache_refresh_type>
|
413 |
+
</observers>
|
414 |
+
</adminhtml_cache_refresh_type>
|
415 |
+
<!-- Cron/Crawler events -->
|
416 |
+
<turpentine_ban_all_cache>
|
417 |
+
<observers>
|
418 |
+
<turpentine_cron_turpentine_ban_all_cache>
|
419 |
+
<class>turpentine/observer_cron</class>
|
420 |
+
<method>queueAllUrls</method>
|
421 |
+
</turpentine_cron_turpentine_ban_all_cache>
|
422 |
+
</observers>
|
423 |
+
</turpentine_ban_all_cache>
|
424 |
+
</events>
|
425 |
+
</global>
|
426 |
+
<frontend>
|
427 |
+
<routers>
|
428 |
+
<turpentine>
|
429 |
+
<use>standard</use>
|
430 |
+
<args>
|
431 |
+
<module>Nexcessnet_Turpentine</module>
|
432 |
+
<frontName>turpentine</frontName>
|
433 |
+
</args>
|
434 |
+
</turpentine>
|
435 |
+
</routers>
|
436 |
+
<layout>
|
437 |
+
<updates>
|
438 |
+
<!--
|
439 |
+
This file should never be edited by a user since it will
|
440 |
+
be overwritten on extension updates
|
441 |
+
-->
|
442 |
+
<turpentine_esi module="turpentine">
|
443 |
+
<file>turpentine_esi.xml</file>
|
444 |
+
</turpentine_esi>
|
445 |
+
</updates>
|
446 |
+
</layout>
|
447 |
+
<events>
|
448 |
+
<controller_action_predispatch>
|
449 |
+
<observers>
|
450 |
+
<controller_action_before>
|
451 |
+
<class>turpentine/observer_esi</class>
|
452 |
+
<method>hookToControllerActionPreDispatch</method>
|
453 |
+
</controller_action_before>
|
454 |
+
</observers>
|
455 |
+
</controller_action_predispatch>
|
456 |
+
<!--controller_action_postdispatch>
|
457 |
+
<observers>
|
458 |
+
<controller_action_after>
|
459 |
+
<class>turpentine/observer_esi</class>
|
460 |
+
<method>hookToControllerActionPostDispatch</method>
|
461 |
+
</controller_action_after>
|
462 |
+
</observers>
|
463 |
+
</controller_action_postdispatch-->
|
464 |
+
<add_to_cart_before>
|
465 |
+
<observers>
|
466 |
+
<add_to_cart_before>
|
467 |
+
<class>turpentine/observer_esi</class>
|
468 |
+
<method>hookToAddToCartBefore</method>
|
469 |
+
</add_to_cart_before>
|
470 |
+
</observers>
|
471 |
+
</add_to_cart_before>
|
472 |
+
<!--add_to_cart_after>
|
473 |
+
<observers>
|
474 |
+
<add_to_cart_after>
|
475 |
+
<class>turpentine/observer_esi</class>
|
476 |
+
<method>hookToAddToCartAfter</method>
|
477 |
+
</add_to_cart_after>
|
478 |
+
</observers>
|
479 |
+
</add_to_cart_after-->
|
480 |
+
<wishlist_index_index_before>
|
481 |
+
<observers>
|
482 |
+
<wishlist_index_index_before>
|
483 |
+
<class>turpentine/observer_esi</class>
|
484 |
+
<method>hookToAddToWishlistBefore</method>
|
485 |
+
</wishlist_index_index_before>
|
486 |
+
</observers>
|
487 |
+
</wishlist_index_index_before>
|
488 |
+
</events>
|
489 |
+
</frontend>
|
490 |
+
<admin>
|
491 |
+
<routers>
|
492 |
+
<adminhtml>
|
493 |
+
<args>
|
494 |
+
<modules>
|
495 |
+
<turpentine after="Mage_Adminhtml">Nexcessnet_Turpentine</turpentine>
|
496 |
+
</modules>
|
497 |
+
</args>
|
498 |
+
</adminhtml>
|
499 |
+
</routers>
|
500 |
+
</admin>
|
501 |
+
<adminhtml>
|
502 |
+
<layout>
|
503 |
+
<updates>
|
504 |
+
<turpentine module="turpentine">
|
505 |
+
<file>turpentine.xml</file>
|
506 |
+
</turpentine>
|
507 |
+
</updates>
|
508 |
+
</layout>
|
509 |
+
<acl>
|
510 |
+
<resources>
|
511 |
+
<admin>
|
512 |
+
<children>
|
513 |
+
<system>
|
514 |
+
<children>
|
515 |
+
<turpentine translate="title" module="turpentine">
|
516 |
+
<title>Turpentine Varnish Management</title>
|
517 |
+
</turpentine>
|
518 |
+
<config>
|
519 |
+
<children>
|
520 |
+
<turpentine_varnish translate="title" module="turpentine">
|
521 |
+
<title>Turpentine Varnish Options</title>
|
522 |
+
</turpentine_varnish>
|
523 |
+
<turpentine_vcl translate="title" module="turpentine">
|
524 |
+
<title>Turpentine Caching Options</title>
|
525 |
+
</turpentine_vcl>
|
526 |
+
</children>
|
527 |
+
</config>
|
528 |
+
</children>
|
529 |
+
</system>
|
530 |
+
</children>
|
531 |
+
</admin>
|
532 |
+
</resources>
|
533 |
+
</acl>
|
534 |
+
</adminhtml>
|
535 |
+
<crontab>
|
536 |
+
<jobs>
|
537 |
+
<turpentine_crawl_urls>
|
538 |
+
<schedule>
|
539 |
+
<cron_expr>0,10,20,30,40,50 * * * *</cron_expr>
|
540 |
+
</schedule>
|
541 |
+
<run>
|
542 |
+
<model>turpentine/observer_cron::crawlUrls</model>
|
543 |
+
</run>
|
544 |
+
</turpentine_crawl_urls>
|
545 |
+
</jobs>
|
546 |
+
</crontab>
|
547 |
+
</config>
|
app/code/community/Nexcessnet/Turpentine/etc/system.xml
CHANGED
@@ -72,6 +72,16 @@
|
|
72 |
<show_in_website>1</show_in_website>
|
73 |
<show_in_store>1</show_in_store>
|
74 |
</vcl_fix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
<https_redirect_fix translate="label comment">
|
76 |
<label>Fix HTTPS redirect</label>
|
77 |
<comment>When using Varnish as front door listen on port 80 and Nginx/Apache listen on port 443 for HTTPS, the fix will keep the url parameters when redirect from HTTP to HTTPS.</comment>
|
72 |
<show_in_website>1</show_in_website>
|
73 |
<show_in_store>1</show_in_store>
|
74 |
</vcl_fix>
|
75 |
+
<https_proto_fix translate="label comment">
|
76 |
+
<label>Set X-Forwarded-Proto Header to HTTPS on port 443</label>
|
77 |
+
<comment>When using Varnish on port 80 and hitch on port 443 for HTTPS, the fix will set X-Forwarded-Proto header to HTTPS to prevent a re-direct loop.</comment>
|
78 |
+
<frontend_type>select</frontend_type>
|
79 |
+
<sort_order>27</sort_order>
|
80 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
81 |
+
<show_in_default>1</show_in_default>
|
82 |
+
<show_in_website>1</show_in_website>
|
83 |
+
<show_in_store>1</show_in_store>
|
84 |
+
</https_proto_fix>
|
85 |
<https_redirect_fix translate="label comment">
|
86 |
<label>Fix HTTPS redirect</label>
|
87 |
<comment>When using Varnish as front door listen on port 80 and Nginx/Apache listen on port 443 for HTTPS, the fix will keep the url parameters when redirect from HTTP to HTTPS.</comment>
|
app/code/community/Nexcessnet/Turpentine/misc/version-2.vcl
CHANGED
@@ -329,7 +329,7 @@ sub vcl_fetch {
|
|
329 |
remove beresp.http.Set-Cookie;
|
330 |
}
|
331 |
# we'll set our own cache headers if we need them
|
332 |
-
|
333 |
remove beresp.http.Expires;
|
334 |
remove beresp.http.Pragma;
|
335 |
remove beresp.http.Cache;
|
@@ -341,6 +341,7 @@ sub vcl_fetch {
|
|
341 |
if (beresp.http.X-Turpentine-Cache == "0") {
|
342 |
set beresp.cacheable = false;
|
343 |
set beresp.ttl = {{grace_period}}s;
|
|
|
344 |
return (pass);
|
345 |
} else {
|
346 |
set beresp.cacheable = true;
|
@@ -360,6 +361,7 @@ sub vcl_fetch {
|
|
360 |
}
|
361 |
if (req.http.X-Varnish-Esi-Method == "ajax") {
|
362 |
set beresp.ttl = {{grace_period}}s;
|
|
|
363 |
return (pass);
|
364 |
} else {
|
365 |
set beresp.ttl = {{esi_private_ttl}}s;
|
329 |
remove beresp.http.Set-Cookie;
|
330 |
}
|
331 |
# we'll set our own cache headers if we need them
|
332 |
+
# we'll override the "Cache-Control" header if needed.
|
333 |
remove beresp.http.Expires;
|
334 |
remove beresp.http.Pragma;
|
335 |
remove beresp.http.Cache;
|
341 |
if (beresp.http.X-Turpentine-Cache == "0") {
|
342 |
set beresp.cacheable = false;
|
343 |
set beresp.ttl = {{grace_period}}s;
|
344 |
+
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate";
|
345 |
return (pass);
|
346 |
} else {
|
347 |
set beresp.cacheable = true;
|
361 |
}
|
362 |
if (req.http.X-Varnish-Esi-Method == "ajax") {
|
363 |
set beresp.ttl = {{grace_period}}s;
|
364 |
+
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate";
|
365 |
return (pass);
|
366 |
} else {
|
367 |
set beresp.ttl = {{esi_private_ttl}}s;
|
app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl
CHANGED
@@ -335,7 +335,7 @@ sub vcl_fetch {
|
|
335 |
unset beresp.http.Set-Cookie;
|
336 |
}
|
337 |
# we'll set our own cache headers if we need them
|
338 |
-
|
339 |
unset beresp.http.Expires;
|
340 |
unset beresp.http.Pragma;
|
341 |
unset beresp.http.Cache;
|
@@ -346,6 +346,7 @@ sub vcl_fetch {
|
|
346 |
}
|
347 |
if (beresp.http.X-Turpentine-Cache == "0") {
|
348 |
set beresp.ttl = {{grace_period}}s;
|
|
|
349 |
return (hit_for_pass);
|
350 |
} else {
|
351 |
if ({{force_cache_static}} &&
|
@@ -374,6 +375,7 @@ sub vcl_fetch {
|
|
374 |
# this is probably faster than bothering with 0 ttl
|
375 |
# cache objects
|
376 |
set beresp.ttl = {{grace_period}}s;
|
|
|
377 |
return (hit_for_pass);
|
378 |
}
|
379 |
} else {
|
335 |
unset beresp.http.Set-Cookie;
|
336 |
}
|
337 |
# we'll set our own cache headers if we need them
|
338 |
+
# we'll override the "Cache-Control" header if needed
|
339 |
unset beresp.http.Expires;
|
340 |
unset beresp.http.Pragma;
|
341 |
unset beresp.http.Cache;
|
346 |
}
|
347 |
if (beresp.http.X-Turpentine-Cache == "0") {
|
348 |
set beresp.ttl = {{grace_period}}s;
|
349 |
+
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate";
|
350 |
return (hit_for_pass);
|
351 |
} else {
|
352 |
if ({{force_cache_static}} &&
|
375 |
# this is probably faster than bothering with 0 ttl
|
376 |
# cache objects
|
377 |
set beresp.ttl = {{grace_period}}s;
|
378 |
+
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate";
|
379 |
return (hit_for_pass);
|
380 |
}
|
381 |
} else {
|
app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl
CHANGED
@@ -109,6 +109,7 @@ sub vcl_init {
|
|
109 |
sub vcl_recv {
|
110 |
{{maintenance_allowed_ips}}
|
111 |
|
|
|
112 |
{{https_redirect}}
|
113 |
|
114 |
# this always needs to be done so it's up at the top
|
@@ -355,8 +356,9 @@ sub vcl_backend_response {
|
|
355 |
set beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie;
|
356 |
unset beresp.http.Set-Cookie;
|
357 |
}
|
|
|
358 |
# we'll set our own cache headers if we need them
|
359 |
-
|
360 |
unset beresp.http.Expires;
|
361 |
unset beresp.http.Pragma;
|
362 |
unset beresp.http.Cache;
|
@@ -368,6 +370,7 @@ sub vcl_backend_response {
|
|
368 |
if (beresp.http.X-Turpentine-Cache == "0") {
|
369 |
set beresp.ttl = {{grace_period}}s;
|
370 |
set beresp.uncacheable = true;
|
|
|
371 |
return (deliver);
|
372 |
} else {
|
373 |
if ({{force_cache_static}} &&
|
@@ -397,6 +400,7 @@ sub vcl_backend_response {
|
|
397 |
# cache objects
|
398 |
set beresp.ttl = {{grace_period}}s;
|
399 |
set beresp.uncacheable = true;
|
|
|
400 |
return (deliver);
|
401 |
}
|
402 |
} else {
|
109 |
sub vcl_recv {
|
110 |
{{maintenance_allowed_ips}}
|
111 |
|
112 |
+
{{https_proto_fix}}
|
113 |
{{https_redirect}}
|
114 |
|
115 |
# this always needs to be done so it's up at the top
|
356 |
set beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie;
|
357 |
unset beresp.http.Set-Cookie;
|
358 |
}
|
359 |
+
|
360 |
# we'll set our own cache headers if we need them
|
361 |
+
# we'll override the "Cache-Control" header if needed
|
362 |
unset beresp.http.Expires;
|
363 |
unset beresp.http.Pragma;
|
364 |
unset beresp.http.Cache;
|
370 |
if (beresp.http.X-Turpentine-Cache == "0") {
|
371 |
set beresp.ttl = {{grace_period}}s;
|
372 |
set beresp.uncacheable = true;
|
373 |
+
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate";
|
374 |
return (deliver);
|
375 |
} else {
|
376 |
if ({{force_cache_static}} &&
|
400 |
# cache objects
|
401 |
set beresp.ttl = {{grace_period}}s;
|
402 |
set beresp.uncacheable = true;
|
403 |
+
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate";
|
404 |
return (deliver);
|
405 |
}
|
406 |
} else {
|
app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl~
ADDED
@@ -0,0 +1,483 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
vcl 4.0;
|
2 |
+
# Nexcess.net Turpentine Extension for Magento
|
3 |
+
# Copyright (C) 2012 Nexcess.net L.L.C.
|
4 |
+
#
|
5 |
+
# This program is free software; you can redistribute it and/or modify
|
6 |
+
# it under the terms of the GNU General Public License as published by
|
7 |
+
# the Free Software Foundation; either version 2 of the License, or
|
8 |
+
# (at your option) any later version.
|
9 |
+
#
|
10 |
+
# This program is distributed in the hope that it will be useful,
|
11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
# GNU General Public License for more details.
|
14 |
+
#
|
15 |
+
# You should have received a copy of the GNU General Public License along
|
16 |
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17 |
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18 |
+
|
19 |
+
## Nexcessnet_Turpentine Varnish v4 VCL Template
|
20 |
+
|
21 |
+
## Custom C Code
|
22 |
+
|
23 |
+
C{
|
24 |
+
// @source app/code/community/Nexcessnet/Turpentine/misc/uuid.c
|
25 |
+
{{custom_c_code}}
|
26 |
+
}C
|
27 |
+
|
28 |
+
## Imports
|
29 |
+
|
30 |
+
import std;
|
31 |
+
import directors;
|
32 |
+
|
33 |
+
## Custom VCL Logic - Top
|
34 |
+
|
35 |
+
{{custom_vcl_include_top}}
|
36 |
+
|
37 |
+
## Backends
|
38 |
+
|
39 |
+
{{default_backend}}
|
40 |
+
|
41 |
+
{{admin_backend}}
|
42 |
+
|
43 |
+
## ACLs
|
44 |
+
|
45 |
+
{{crawler_acl}}
|
46 |
+
|
47 |
+
{{debug_acl}}
|
48 |
+
|
49 |
+
## Custom Subroutines
|
50 |
+
|
51 |
+
{{generate_session_start}}
|
52 |
+
sub generate_session {
|
53 |
+
# generate a UUID and add `frontend=$UUID` to the Cookie header, or use SID
|
54 |
+
# from SID URL param
|
55 |
+
if (req.url ~ ".*[&?]SID=([^&]+).*") {
|
56 |
+
set req.http.X-Varnish-Faked-Session = regsub(
|
57 |
+
req.url, ".*[&?]SID=([^&]+).*", "frontend=\1");
|
58 |
+
} else {
|
59 |
+
C{
|
60 |
+
char uuid_buf [50];
|
61 |
+
generate_uuid(uuid_buf);
|
62 |
+
static const struct gethdr_s VGC_HDR_REQ_VARNISH_FAKED_SESSION =
|
63 |
+
{ HDR_REQ, "\030X-Varnish-Faked-Session:"};
|
64 |
+
VRT_SetHdr(ctx,
|
65 |
+
&VGC_HDR_REQ_VARNISH_FAKED_SESSION,
|
66 |
+
uuid_buf,
|
67 |
+
vrt_magic_string_end
|
68 |
+
);
|
69 |
+
}C
|
70 |
+
}
|
71 |
+
if (req.http.Cookie) {
|
72 |
+
# client sent us cookies, just not a frontend cookie. try not to blow
|
73 |
+
# away the extra cookies
|
74 |
+
std.collect(req.http.Cookie);
|
75 |
+
set req.http.Cookie = req.http.X-Varnish-Faked-Session +
|
76 |
+
"; " + req.http.Cookie;
|
77 |
+
} else {
|
78 |
+
set req.http.Cookie = req.http.X-Varnish-Faked-Session;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
sub generate_session_expires {
|
83 |
+
# sets X-Varnish-Cookie-Expires to now + esi_private_ttl in format:
|
84 |
+
# Tue, 19-Feb-2013 00:14:27 GMT
|
85 |
+
# this isn't threadsafe but it shouldn't matter in this case
|
86 |
+
C{
|
87 |
+
time_t now = time(NULL);
|
88 |
+
struct tm now_tm = *gmtime(&now);
|
89 |
+
now_tm.tm_sec += {{esi_private_ttl}};
|
90 |
+
mktime(&now_tm);
|
91 |
+
char date_buf [50];
|
92 |
+
strftime(date_buf, sizeof(date_buf)-1, "%a, %d-%b-%Y %H:%M:%S %Z", &now_tm);
|
93 |
+
static const struct gethdr_s VGC_HDR_RESP_COOKIE_EXPIRES =
|
94 |
+
{ HDR_RESP, "\031X-Varnish-Cookie-Expires:"};
|
95 |
+
VRT_SetHdr(ctx,
|
96 |
+
&VGC_HDR_RESP_COOKIE_EXPIRES,
|
97 |
+
date_buf,
|
98 |
+
vrt_magic_string_end
|
99 |
+
);
|
100 |
+
}C
|
101 |
+
}
|
102 |
+
{{generate_session_end}}
|
103 |
+
## Varnish Subroutines
|
104 |
+
|
105 |
+
sub vcl_synth {
|
106 |
+
if (resp.status == 750) {
|
107 |
+
set resp.status = 301;
|
108 |
+
set resp.http.Location = "https://" + req.http.host + req.url;
|
109 |
+
return(deliver);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
sub vcl_init {
|
114 |
+
{{directors}}
|
115 |
+
}
|
116 |
+
|
117 |
+
sub vcl_recv {
|
118 |
+
{{maintenance_allowed_ips}}
|
119 |
+
|
120 |
+
{{https_redirect}}
|
121 |
+
|
122 |
+
# this always needs to be done so it's up at the top
|
123 |
+
if (req.restarts == 0) {
|
124 |
+
if (req.http.X-Forwarded-For) {
|
125 |
+
set req.http.X-Forwarded-For =
|
126 |
+
req.http.X-Forwarded-For + ", " + client.ip;
|
127 |
+
} else {
|
128 |
+
set req.http.X-Forwarded-For = client.ip;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
# We only deal with GET and HEAD by default
|
133 |
+
# we test this here instead of inside the url base regex section
|
134 |
+
# so we can disable caching for the entire site if needed
|
135 |
+
if (!{{enable_caching}} || req.http.Authorization ||
|
136 |
+
req.method !~ "^(GET|HEAD|OPTIONS)$" ||
|
137 |
+
req.http.Cookie ~ "varnish_bypass={{secret_handshake}}") {
|
138 |
+
return (pass);
|
139 |
+
}
|
140 |
+
|
141 |
+
if({{send_unmodified_url}}) {
|
142 |
+
# save the unmodified url
|
143 |
+
set req.http.X-Varnish-Origin-Url = req.url;
|
144 |
+
}
|
145 |
+
|
146 |
+
# remove double slashes from the URL, for higher cache hit rate
|
147 |
+
set req.url = regsuball(req.url, "(.*)//+(.*)", "\1/\2");
|
148 |
+
|
149 |
+
{{normalize_encoding}}
|
150 |
+
{{normalize_user_agent}}
|
151 |
+
{{normalize_host}}
|
152 |
+
|
153 |
+
# check if the request is for part of magento
|
154 |
+
if (req.url ~ "{{url_base_regex}}") {
|
155 |
+
# set this so Turpentine can see the request passed through Varnish
|
156 |
+
set req.http.X-Turpentine-Secret-Handshake = "{{secret_handshake}}";
|
157 |
+
# use the special admin backend and pipe if it's for the admin section
|
158 |
+
if (req.url ~ "{{url_base_regex}}{{admin_frontname}}") {
|
159 |
+
set req.backend_hint = {{admin_backend_hint}};
|
160 |
+
return (pipe);
|
161 |
+
} else {
|
162 |
+
{{set_backend_hint}}
|
163 |
+
}
|
164 |
+
if (req.http.Cookie ~ "\bcurrency=") {
|
165 |
+
set req.http.X-Varnish-Currency = regsub(
|
166 |
+
req.http.Cookie, ".*\bcurrency=([^;]*).*", "\1");
|
167 |
+
}
|
168 |
+
if (req.http.Cookie ~ "\bstore=") {
|
169 |
+
set req.http.X-Varnish-Store = regsub(
|
170 |
+
req.http.Cookie, ".*\bstore=([^;]*).*", "\1");
|
171 |
+
}
|
172 |
+
# looks like an ESI request, add some extra vars for further processing
|
173 |
+
if (req.url ~ "/turpentine/esi/get(?:Block|FormKey)/") {
|
174 |
+
set req.http.X-Varnish-Esi-Method = regsub(
|
175 |
+
req.url, ".*/{{esi_method_param}}/(\w+)/.*", "\1");
|
176 |
+
set req.http.X-Varnish-Esi-Access = regsub(
|
177 |
+
req.url, ".*/{{esi_cache_type_param}}/(\w+)/.*", "\1");
|
178 |
+
|
179 |
+
# throw a forbidden error if debugging is off and a esi block is
|
180 |
+
# requested by the user (does not apply to ajax blocks)
|
181 |
+
if (req.http.X-Varnish-Esi-Method == "esi" && req.esi_level == 0 &&
|
182 |
+
!({{debug_headers}} || client.ip ~ debug_acl)) {
|
183 |
+
return (synth(403, "External ESI requests are not allowed"));
|
184 |
+
}
|
185 |
+
}
|
186 |
+
{{allowed_hosts}}
|
187 |
+
# no frontend cookie was sent to us AND this is not an ESI or AJAX call
|
188 |
+
if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) {
|
189 |
+
if (client.ip ~ crawler_acl ||
|
190 |
+
req.http.User-Agent ~ "^(?:{{crawler_user_agent_regex}})$") {
|
191 |
+
# it's a crawler, give it a fake cookie
|
192 |
+
set req.http.Cookie = "frontend=crawler-session";
|
193 |
+
} else {
|
194 |
+
# it's a real user, make up a new session for them
|
195 |
+
{{generate_session}}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
if ({{force_cache_static}} &&
|
199 |
+
req.url ~ ".*\.(?:{{static_extensions}})(?=\?|&|$)") {
|
200 |
+
# don't need cookies for static assets
|
201 |
+
unset req.http.Cookie;
|
202 |
+
unset req.http.X-Varnish-Faked-Session;
|
203 |
+
set req.http.X-Varnish-Static = 1;
|
204 |
+
return (hash);
|
205 |
+
}
|
206 |
+
# this doesn't need a enable_url_excludes because we can be reasonably
|
207 |
+
# certain that cron.php at least will always be in it, so it will
|
208 |
+
# never be empty
|
209 |
+
if (req.url ~ "{{url_base_regex}}(?:{{url_excludes}})" ||
|
210 |
+
# user switched stores. we pipe this instead of passing below because
|
211 |
+
# switching stores doesn't redirect (302), just acts like a link to
|
212 |
+
# another page (200) so the Set-Cookie header would be removed
|
213 |
+
req.url ~ "\?.*__from_store=") {
|
214 |
+
return (pipe);
|
215 |
+
}
|
216 |
+
if ({{enable_get_excludes}} &&
|
217 |
+
req.url ~ "(?:[?&](?:{{get_param_excludes}})(?=[&=]|$))") {
|
218 |
+
# TODO: should this be pass or pipe?
|
219 |
+
return (pass);
|
220 |
+
}
|
221 |
+
if (req.url ~ "[?&](utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=") {
|
222 |
+
# Strip out Google related parameters
|
223 |
+
set req.url = regsuball(req.url, "(?:(\?)?|&)(?:utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=[^&]+", "\1");
|
224 |
+
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
|
225 |
+
}
|
226 |
+
|
227 |
+
if ({{enable_get_ignored}} && req.url ~ "[?&]({{get_param_ignored}})=") {
|
228 |
+
# Strip out Ignored GET parameters
|
229 |
+
set req.url = regsuball(req.url, "(?:(\?)?|&)(?:{{get_param_ignored}})=[^&]+", "\1");
|
230 |
+
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
|
231 |
+
}
|
232 |
+
|
233 |
+
if({{send_unmodified_url}}) {
|
234 |
+
set req.http.X-Varnish-Cache-Url = req.url;
|
235 |
+
set req.url = req.http.X-Varnish-Origin-Url;
|
236 |
+
unset req.http.X-Varnish-Origin-Url;
|
237 |
+
}
|
238 |
+
|
239 |
+
# everything else checks out, try and pull from the cache
|
240 |
+
return (hash);
|
241 |
+
}
|
242 |
+
# else it's not part of magento so do default handling (doesn't help
|
243 |
+
# things underneath magento but we can't detect that)
|
244 |
+
}
|
245 |
+
|
246 |
+
sub vcl_pipe {
|
247 |
+
# since we're not going to do any stuff to the response we pretend the
|
248 |
+
# request didn't pass through Varnish
|
249 |
+
unset bereq.http.X-Turpentine-Secret-Handshake;
|
250 |
+
set bereq.http.Connection = "close";
|
251 |
+
}
|
252 |
+
|
253 |
+
# sub vcl_pass {
|
254 |
+
# return (pass);
|
255 |
+
# }
|
256 |
+
|
257 |
+
sub vcl_hash {
|
258 |
+
std.log("vcl_hash start");
|
259 |
+
|
260 |
+
# For static files we keep the hash simple and don't add the domain.
|
261 |
+
# This saves memory when a static file is used on multiple domains.
|
262 |
+
if ({{simple_hash_static}} && req.http.X-Varnish-Static) {
|
263 |
+
std.log("hash_data static file - req.url: " + req.url);
|
264 |
+
hash_data(req.url);
|
265 |
+
if (req.http.Accept-Encoding) {
|
266 |
+
# make sure we give back the right encoding
|
267 |
+
std.log("hash_data static file - Accept-Encoding: " + req.http.Accept-Encoding);
|
268 |
+
hash_data(req.http.Accept-Encoding);
|
269 |
+
}
|
270 |
+
std.log("vcl_hash end return lookup");
|
271 |
+
return (lookup);
|
272 |
+
}
|
273 |
+
|
274 |
+
|
275 |
+
if({{send_unmodified_url}} && req.http.X-Varnish-Cache-Url) {
|
276 |
+
hash_data(req.http.X-Varnish-Cache-Url);
|
277 |
+
std.log("hash_data - X-Varnish-Cache-Url: " + req.http.X-Varnish-Cache-Url);
|
278 |
+
} else {
|
279 |
+
hash_data(req.url);
|
280 |
+
std.log("hash_data - req.url: " + req.url );
|
281 |
+
}
|
282 |
+
|
283 |
+
if (req.http.Host) {
|
284 |
+
hash_data(req.http.Host);
|
285 |
+
std.log("hash_data - req.http.Host: " + req.http.Host);
|
286 |
+
} else {
|
287 |
+
hash_data(server.ip);
|
288 |
+
}
|
289 |
+
|
290 |
+
std.log("hash_data - req.http.Ssl-Offloaded: " + req.http.Ssl-Offloaded);
|
291 |
+
hash_data(req.http.Ssl-Offloaded);
|
292 |
+
|
293 |
+
if (req.http.X-Normalized-User-Agent) {
|
294 |
+
hash_data(req.http.X-Normalized-User-Agent);
|
295 |
+
std.log("hash_data - req.http.X-Normalized-User-Agent: " + req.http.X-Normalized-User-Agent);
|
296 |
+
}
|
297 |
+
if (req.http.Accept-Encoding) {
|
298 |
+
# make sure we give back the right encoding
|
299 |
+
hash_data(req.http.Accept-Encoding);
|
300 |
+
std.log("hash_data - req.http.Accept-Encoding: " + req.http.Accept-Encoding);
|
301 |
+
}
|
302 |
+
if (req.http.X-Varnish-Store || req.http.X-Varnish-Currency) {
|
303 |
+
# make sure data is for the right store and currency based on the *store*
|
304 |
+
# and *currency* cookies
|
305 |
+
hash_data("s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency);
|
306 |
+
std.log("hash_data - Store and Currency: " + "s=" + req.http.X-Varnish-Store + "&c=" + req.http.X-Varnish-Currency);
|
307 |
+
}
|
308 |
+
|
309 |
+
if (req.http.X-Varnish-Esi-Access == "private" &&
|
310 |
+
req.http.Cookie ~ "frontend=") {
|
311 |
+
std.log("hash_data - frontned cookie: " + regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1"));
|
312 |
+
hash_data(regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1"));
|
313 |
+
{{advanced_session_validation}}
|
314 |
+
|
315 |
+
}
|
316 |
+
<<<<<<< HEAD
|
317 |
+
std.log("vcl_hash end return lookup");
|
318 |
+
=======
|
319 |
+
|
320 |
+
if (req.http.X-Varnish-Esi-Access == "customer_group" &&
|
321 |
+
req.http.Cookie ~ "customer_group=") {
|
322 |
+
hash_data(regsub(req.http.Cookie, "^.*?customer_group=([^;]*);*.*$", "\1"));
|
323 |
+
}
|
324 |
+
>>>>>>> master
|
325 |
+
return (lookup);
|
326 |
+
}
|
327 |
+
|
328 |
+
sub vcl_hit {
|
329 |
+
# this seems to cause cache object contention issues so removed for now
|
330 |
+
# TODO: use obj.hits % something maybe
|
331 |
+
# if (obj.hits > 0) {
|
332 |
+
# set obj.ttl = obj.ttl + {{lru_factor}}s;
|
333 |
+
# }
|
334 |
+
}
|
335 |
+
|
336 |
+
# sub vcl_miss {
|
337 |
+
# return (fetch);
|
338 |
+
# }
|
339 |
+
|
340 |
+
sub vcl_backend_response {
|
341 |
+
# set the grace period
|
342 |
+
set beresp.grace = {{grace_period}}s;
|
343 |
+
|
344 |
+
# Store the URL in the response object, to be able to do lurker friendly bans later
|
345 |
+
set beresp.http.X-Varnish-Host = bereq.http.host;
|
346 |
+
set beresp.http.X-Varnish-URL = bereq.url;
|
347 |
+
|
348 |
+
# if it's part of magento...
|
349 |
+
if (bereq.url ~ "{{url_base_regex}}") {
|
350 |
+
# we handle the Vary stuff ourselves for now, we'll want to actually
|
351 |
+
# use this eventually for compatibility with downstream proxies
|
352 |
+
# TODO: only remove the User-Agent field from this if it exists
|
353 |
+
unset beresp.http.Vary;
|
354 |
+
# we pretty much always want to do this
|
355 |
+
set beresp.do_gzip = true;
|
356 |
+
|
357 |
+
if (beresp.status != 200 && beresp.status != 404) {
|
358 |
+
# pass anything that isn't a 200 or 404
|
359 |
+
set beresp.ttl = {{grace_period}}s;
|
360 |
+
set beresp.uncacheable = true;
|
361 |
+
return (deliver);
|
362 |
+
} else {
|
363 |
+
# if Magento sent us a Set-Cookie header, we'll put it somewhere
|
364 |
+
# else for now
|
365 |
+
if (beresp.http.Set-Cookie) {
|
366 |
+
set beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie;
|
367 |
+
unset beresp.http.Set-Cookie;
|
368 |
+
}
|
369 |
+
# we'll set our own cache headers if we need them
|
370 |
+
unset beresp.http.Cache-Control;
|
371 |
+
unset beresp.http.Expires;
|
372 |
+
unset beresp.http.Pragma;
|
373 |
+
unset beresp.http.Cache;
|
374 |
+
unset beresp.http.Age;
|
375 |
+
|
376 |
+
if (beresp.http.X-Turpentine-Esi == "1") {
|
377 |
+
set beresp.do_esi = true;
|
378 |
+
}
|
379 |
+
if (beresp.http.X-Turpentine-Cache == "0") {
|
380 |
+
set beresp.ttl = {{grace_period}}s;
|
381 |
+
set beresp.uncacheable = true;
|
382 |
+
return (deliver);
|
383 |
+
} else {
|
384 |
+
if ({{force_cache_static}} &&
|
385 |
+
bereq.url ~ ".*\.(?:{{static_extensions}})(?=\?|&|$)") {
|
386 |
+
# it's a static asset
|
387 |
+
set beresp.ttl = {{static_ttl}}s;
|
388 |
+
set beresp.http.Cache-Control = "max-age={{static_ttl}}";
|
389 |
+
} elseif (bereq.http.X-Varnish-Esi-Method) {
|
390 |
+
# it's a ESI request
|
391 |
+
if (bereq.http.X-Varnish-Esi-Access == "private" &&
|
392 |
+
bereq.http.Cookie ~ "frontend=") {
|
393 |
+
# set this header so we can ban by session from Turpentine
|
394 |
+
set beresp.http.X-Varnish-Session = regsub(bereq.http.Cookie,
|
395 |
+
"^.*?frontend=([^;]*);*.*$", "\1");
|
396 |
+
}
|
397 |
+
if (bereq.http.X-Varnish-Esi-Method == "ajax" &&
|
398 |
+
bereq.http.X-Varnish-Esi-Access == "public") {
|
399 |
+
set beresp.http.Cache-Control = "max-age=" + regsub(
|
400 |
+
bereq.url, ".*/{{esi_ttl_param}}/(\d+)/.*", "\1");
|
401 |
+
}
|
402 |
+
set beresp.ttl = std.duration(
|
403 |
+
regsub(
|
404 |
+
bereq.url, ".*/{{esi_ttl_param}}/(\d+)/.*", "\1s"),
|
405 |
+
300s);
|
406 |
+
if (beresp.ttl == 0s) {
|
407 |
+
# this is probably faster than bothering with 0 ttl
|
408 |
+
# cache objects
|
409 |
+
set beresp.ttl = {{grace_period}}s;
|
410 |
+
set beresp.uncacheable = true;
|
411 |
+
return (deliver);
|
412 |
+
}
|
413 |
+
} else {
|
414 |
+
{{url_ttls}}
|
415 |
+
}
|
416 |
+
}
|
417 |
+
}
|
418 |
+
# we've done what we need to, send to the client
|
419 |
+
return (deliver);
|
420 |
+
}
|
421 |
+
# else it's not part of Magento so use the default Varnish handling
|
422 |
+
}
|
423 |
+
|
424 |
+
{{vcl_synth}}
|
425 |
+
|
426 |
+
sub vcl_deliver {
|
427 |
+
if (req.http.X-Varnish-Faked-Session) {
|
428 |
+
# need to set the set-cookie header since we just made it out of thin air
|
429 |
+
{{generate_session_expires}}
|
430 |
+
set resp.http.Set-Cookie = req.http.X-Varnish-Faked-Session +
|
431 |
+
"; expires=" + resp.http.X-Varnish-Cookie-Expires + "; path=/";
|
432 |
+
if (req.http.Host) {
|
433 |
+
if (req.http.User-Agent ~ "^(?:{{crawler_user_agent_regex}})$") {
|
434 |
+
# it's a crawler, no need to share cookies
|
435 |
+
set resp.http.Set-Cookie = resp.http.Set-Cookie +
|
436 |
+
"; domain=" + regsub(req.http.Host, ":\d+$", "");
|
437 |
+
} else {
|
438 |
+
# it's a real user, allow sharing of cookies between stores
|
439 |
+
if (req.http.Host ~ "{{normalize_cookie_regex}}" && "{{normalize_cookie_regex}}" ~ "..") {
|
440 |
+
set resp.http.Set-Cookie = resp.http.Set-Cookie +
|
441 |
+
"; domain={{normalize_cookie_target}}";
|
442 |
+
} else {
|
443 |
+
set resp.http.Set-Cookie = resp.http.Set-Cookie +
|
444 |
+
"; domain=" + regsub(req.http.Host, ":\d+$", "");
|
445 |
+
}
|
446 |
+
}
|
447 |
+
}
|
448 |
+
set resp.http.Set-Cookie = resp.http.Set-Cookie + "; httponly";
|
449 |
+
unset resp.http.X-Varnish-Cookie-Expires;
|
450 |
+
}
|
451 |
+
if (req.http.X-Varnish-Esi-Method == "ajax" && req.http.X-Varnish-Esi-Access == "private") {
|
452 |
+
set resp.http.Cache-Control = "no-cache";
|
453 |
+
}
|
454 |
+
if ({{debug_headers}} || client.ip ~ debug_acl) {
|
455 |
+
# debugging is on, give some extra info
|
456 |
+
set resp.http.X-Varnish-Hits = obj.hits;
|
457 |
+
set resp.http.X-Varnish-Esi-Method = req.http.X-Varnish-Esi-Method;
|
458 |
+
set resp.http.X-Varnish-Esi-Access = req.http.X-Varnish-Esi-Access;
|
459 |
+
set resp.http.X-Varnish-Currency = req.http.X-Varnish-Currency;
|
460 |
+
set resp.http.X-Varnish-Store = req.http.X-Varnish-Store;
|
461 |
+
} else {
|
462 |
+
# remove Varnish fingerprints
|
463 |
+
unset resp.http.X-Varnish;
|
464 |
+
unset resp.http.Via;
|
465 |
+
unset resp.http.X-Powered-By;
|
466 |
+
unset resp.http.Server;
|
467 |
+
unset resp.http.X-Turpentine-Cache;
|
468 |
+
unset resp.http.X-Turpentine-Esi;
|
469 |
+
unset resp.http.X-Turpentine-Flush-Events;
|
470 |
+
unset resp.http.X-Turpentine-Block;
|
471 |
+
unset resp.http.X-Varnish-Session;
|
472 |
+
unset resp.http.X-Varnish-Host;
|
473 |
+
unset resp.http.X-Varnish-URL;
|
474 |
+
# this header indicates the session that originally generated a cached
|
475 |
+
# page. it *must* not be sent to a client in production with lax
|
476 |
+
# session validation or that session can be hijacked
|
477 |
+
unset resp.http.X-Varnish-Set-Cookie;
|
478 |
+
}
|
479 |
+
}
|
480 |
+
|
481 |
+
## Custom VCL Logic - Bottom
|
482 |
+
|
483 |
+
{{custom_vcl_include}}
|
package.xml
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?xml version='1.0' encoding='utf-8'?>
|
2 |
-
<package><name>Nexcessnet_Turpentine</name><license uri="http://opensource.org/licenses/GPL-2.0">GPLv2</license><notes>Supports Magento v1.6 and later</notes><time>
|
1 |
<?xml version='1.0' encoding='utf-8'?>
|
2 |
+
<package><name>Nexcessnet_Turpentine</name><license uri="http://opensource.org/licenses/GPL-2.0">GPLv2</license><notes>Supports Magento v1.6 and later</notes><time>10:14:48</time><__packager>build_package.py v0.0.3</__packager><summary>Improves Magento support for Varnish caching and generates 2.1 and 3.0 compatible VCLs.</summary><stability>stable</stability><__commit_hash>298c093f419e156341f86719f72f38befa6f2309</__commit_hash><version>0.7.3</version><extends /><contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file hash="a0bd4a5632b369b058c0ec5262e0cc49" name="turpentine.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="b564606032d111537d02c8da63470c39" name="varnish_management.phtml" /></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file hash="c77b5ace7bf2300de8cab000c5ccb127" name="turpentine_esi.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="b268c48251ccfccf5c775d3e85513584" name="esi.phtml" /><file hash="50798888953fd1550e4347c39e395d0a" name="notices.phtml" /><file hash="4369ad60461aaf69a17a3357c8fe16c6" name="ajax.phtml" /></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file hash="58848d4d90973bfd63b466ea181352a5" name="Nexcessnet_Turpentine.xml" /></dir></target><target name="magecommunity"><dir name="Nexcessnet"><dir name="Turpentine"><dir name="controllers"><file hash="32b46f18f46e1998a993e95fcba5b936" name="EsiController.php" /><dir name="Varnish"><file hash="36ed74dba513b500b7a25175d43a4d71" name="ManagementController.php" /></dir><dir name="Adminhtml"><file hash="9ed581279364b21ead6ad07ff951d90e" name="CacheController.php" /></dir></dir><dir name="Helper"><file hash="a1a0b6aa02aff34f995d3df15c993978" name="Cron.php" /><file hash="c6068752ae71f7fbf58208263d94880d" name="Ban.php" /><file hash="66399790e7dda35e709b346889a21b1b" name="Debug.php" /><file hash="bb7e501af8ebb74bb06b30098b1cf711" name="Esi.php" /><file hash="99ec12c46fd42fbfabdb191c4af7fbe6" name="Varnish.php" /><file hash="193775458c5fa27cde724aae8b54f489" name="Data.php" /></dir><dir name="misc"><file hash="004b7719a403498e3d82e305a715c205" name="version-2.vcl" /><file hash="ba5d5c7263cd90eea3785953e3549041" name="uuid.c" /><file hash="aaf30774e74de801539a7ad32c299604" name="version-3.vcl" /><file hash="27f72d71991a56d88c838aad97ae6bf6" name="version-4.vcl~" /><file hash="8bf591fd1fd8b925c652b1a3a359928a" name="version-4.vcl" /></dir><dir name="etc"><file hash="999f4405d6bdfd1e1d829f89e1a92753" name="config.xml" /><file hash="0940df97e66a9d433eb7d2d1746692ce" name="system.xml" /><file hash="0afc574e11c02dc9bd95473721e3893f" name="config.xml~" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /></dir><dir name="Block"><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><file hash="65b7bc93cb512a208e0f48615996a7e2" name="Management.php" /><dir name="Adminhtml"><dir name="Cache"><file hash="8265061356f8096fc82c88334b4effc9" name="Grid.php" /></dir></dir><dir name="Poll"><file hash="7e9999bf5f3413294d6eebcd3055538b" name="ActivePoll.php" /></dir><dir name="Product"><file hash="c86f7e0571583011932b8bad37aa5acd" name="Viewed.php" /><file hash="e907d4de82aba5be25272127674a10e3" name="Compared.php" /></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file hash="ce9fca4c273987759f284fe31c1597f5" name="Toolbar.php" /></dir></dir></dir><dir name="Core"><file hash="2b4c814c8aa426fa586459716d7c2659" name="Messages.php" /></dir></dir><dir name="Model"><file hash="ffd2af1c58782a2086422b2077f00282" name="Session.php" /><dir name="Varnish"><file hash="05de939cec213969c52b3befa8e0ed3b" name="Admin.php" /><dir name="Configurator"><file hash="83bafa6d8f2fa1e1ab7d2247aab1c9ad" name="Version4.php" /><file hash="d4d66168e43a62ceab30226b44b9e98b" name="Version2.php" /><file hash="a2c28ec0fb5a0c36b82a55cd142ed5ba" name="Abstract.php" /><file hash="b5a6b0206dfdb4168941070e49171192" name="Version3.php" /></dir><dir name="Admin"><file hash="d376269b433f2baabac41523c1a3d449" name="Socket.php" /></dir></dir><dir name="PageCache"><dir name="Container"><file hash="6e3b54ae5968af644952b00cd96a3f32" name="Notices.php" /></dir></dir><dir name="Config"><dir name="Select"><file hash="f615bf43f491c6465b19fd7d7d53d283" name="Version.php" /><file hash="f411ae6da3c2154e78e0f7e845212166" name="StripWhitespace.php" /><file hash="9348c5e58037fd97d89b84ccab4ef2d0" name="Toggle.php" /><file hash="2a4648995fc87472b2ac33b35a7d69e5" name="LoadBalancing.php" /></dir></dir><dir name="Dummy"><file hash="07e4db6d82110e523d1400dcfec60830" name="Request.php" /></dir><dir name="Shim"><dir name="Mage"><dir name="Core"><file hash="5912fa8ef25346f2a21316d8ea5de867" name="Config.php" /><file hash="ee6924c626916a8edd49b6037809204a" name="Layout.php" /><file hash="85e9e378b8fd0ab504c751a69d0b28a6" name="App.php" /></dir></dir></dir><dir name="Observer"><file hash="acdb0304a8b89ae5f072d523be63d9c0" name="Cron.php" /><file hash="bdf76e0eb3b31341ae0d80beba83d85b" name="Ban.php" /><file hash="4f67e6d7c35891451391b13a0eec9847" name="Debug.php" /><file hash="d9e8a19490b888a08bccca95724b7f0c" name="Esi.php" /><file hash="dfda7ae2d0a3fc7db5c5b9fbbd8e9f7c" name="Varnish.php" /></dir><dir name="Core"><file hash="a557f38e6211582bb37bddb94e007511" name="Session.php" /></dir></dir></dir></dir></target></contents><dependencies><required><php><min>5.2.13</min><max>7.1.0</max></php></required></dependencies><authors><author><name>Chris Wells</name><user>nexcess_net</user><email>clwells@nexcess.net</email></author><author><name>Alex Headley</name><user>aheadley_nex</user><email>aheadley@nexcess.net</email></author></authors><date>2017-07-24</date><compatibile /><channel>community</channel><description>Turpentine is a Magento extension to improve Magento's compatibility with Varnish, a very-fast caching reverse-proxy. By default, Varnish doesn't cache requests with cookies and Magento sends the frontend cookie with every request causing a (near) zero hit-rate for Varnish's cache. Turpentine provides Varnish configuration files (VCLs) to work with Magento and modifies Magento's behaviour to significantly improve the cache hit rate.</description></package>
|