Version Notes
Supports Magento v1.6 and later
Download this release
Release Info
Developer | Chris Wells |
Extension | Nexcessnet_Turpentine |
Version | 0.6.7 |
Comparing to | |
See all releases |
Code changes from version 0.6.6 to 0.6.7
- app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php +7 -4
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php +7 -1
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +104 -2
- app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php +0 -3
- app/code/community/Nexcessnet/Turpentine/etc/config.xml +2 -1
- app/code/community/Nexcessnet/Turpentine/etc/config.xml~ +2 -1
- app/code/community/Nexcessnet/Turpentine/etc/system.xml +43 -0
- app/code/community/Nexcessnet/Turpentine/misc/version-2.vcl +22 -1
- app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl +21 -3
- app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +25 -5
- package.xml +1 -1
app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php
CHANGED
@@ -230,6 +230,11 @@ class Nexcessnet_Turpentine_Model_Observer_Esi extends Varien_Event_Observer {
|
|
230 |
if( $esiHelper->shouldResponseUseEsi() &&
|
231 |
$blockObject instanceof Mage_Core_Block_Template &&
|
232 |
$esiOptions = $blockObject->getEsiOptions() ) {
|
|
|
|
|
|
|
|
|
|
|
233 |
if( Mage::app()->getStore()->getCode() == 'admin' ) {
|
234 |
// admin blocks are not allowed to be cached for now
|
235 |
$debugHelper->logWarn(
|
@@ -320,8 +325,6 @@ class Nexcessnet_Turpentine_Model_Observer_Esi extends Varien_Event_Observer {
|
|
320 |
$methodParam = $esiHelper->getEsiMethodParam();
|
321 |
$esiData = new Varien_Object();
|
322 |
$esiData->setStoreId( Mage::app()->getStore()->getId() );
|
323 |
-
$esiData->setDesignPackage( Mage::getDesign()->getPackageName() );
|
324 |
-
$esiData->setDesignTheme( Mage::getDesign()->getTheme( 'layout' ) );
|
325 |
$esiData->setNameInLayout( $blockObject->getNameInLayout() );
|
326 |
$esiData->setBlockType( get_class( $blockObject ) );
|
327 |
$esiData->setLayoutHandles( $this->_getBlockLayoutHandles( $blockObject ) );
|
@@ -413,9 +416,9 @@ class Nexcessnet_Turpentine_Model_Observer_Esi extends Varien_Event_Observer {
|
|
413 |
// check if this handle has any block or reference tags that
|
414 |
// refer to this block or a child block, unless the handle name
|
415 |
// is blank
|
416 |
-
if( $handle !== '' &&
|
417 |
$layoutXml->xpath( sprintf(
|
418 |
-
'//%s//*[@name=\'%s\']', $handle, $blockName ) ) ) {
|
419 |
$activeHandles[] = $handle;
|
420 |
}
|
421 |
}
|
230 |
if( $esiHelper->shouldResponseUseEsi() &&
|
231 |
$blockObject instanceof Mage_Core_Block_Template &&
|
232 |
$esiOptions = $blockObject->getEsiOptions() ) {
|
233 |
+
|
234 |
+
if ((isset($esiOptions['disableEsiInjection'])) && ($esiOptions['disableEsiInjection'] == 1)) {
|
235 |
+
return;
|
236 |
+
}
|
237 |
+
|
238 |
if( Mage::app()->getStore()->getCode() == 'admin' ) {
|
239 |
// admin blocks are not allowed to be cached for now
|
240 |
$debugHelper->logWarn(
|
325 |
$methodParam = $esiHelper->getEsiMethodParam();
|
326 |
$esiData = new Varien_Object();
|
327 |
$esiData->setStoreId( Mage::app()->getStore()->getId() );
|
|
|
|
|
328 |
$esiData->setNameInLayout( $blockObject->getNameInLayout() );
|
329 |
$esiData->setBlockType( get_class( $blockObject ) );
|
330 |
$esiData->setLayoutHandles( $this->_getBlockLayoutHandles( $blockObject ) );
|
416 |
// check if this handle has any block or reference tags that
|
417 |
// refer to this block or a child block, unless the handle name
|
418 |
// is blank
|
419 |
+
if( $handle !== '' && ( strpos($handle, 'THEME') === 0 ||
|
420 |
$layoutXml->xpath( sprintf(
|
421 |
+
'//%s//*[@name=\'%s\']', $handle, $blockName ) ) ) ) {
|
422 |
$activeHandles[] = $handle;
|
423 |
}
|
424 |
}
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php
CHANGED
@@ -359,7 +359,13 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket {
|
|
359 |
Mage::throwException('Varnish versions before 2.1 are not supported');
|
360 |
}
|
361 |
if ( count($bannerText)<7 ) {
|
362 |
-
// Varnish before 3.0 does not spit out a version number
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
return '2.1';
|
364 |
} elseif ( preg_match(self::REGEXP_VARNISH_VERSION, $bannerText[4], $matches)===1 ) {
|
365 |
return $matches['vmajor'] . '.' . $matches['vminor'];
|
359 |
Mage::throwException('Varnish versions before 2.1 are not supported');
|
360 |
}
|
361 |
if ( count($bannerText)<7 ) {
|
362 |
+
// Varnish before 3.0.4 does not spit out a version number
|
363 |
+
$resp = $this->_write( 'help' )->_read();
|
364 |
+
if( strpos( $resp['text'], 'ban.url' ) !== false ) {
|
365 |
+
// Varnish versions 3.0 through 3.0.3 do not return a version banner.
|
366 |
+
// To differentiate between 2.1 and 3.0, we check the existence of the ban.url command.
|
367 |
+
return '3.0';
|
368 |
+
}
|
369 |
return '2.1';
|
370 |
} elseif ( preg_match(self::REGEXP_VARNISH_VERSION, $bannerText[4], $matches)===1 ) {
|
371 |
return $matches['vmajor'] . '.' . $matches['vminor'];
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php
CHANGED
@@ -379,6 +379,14 @@ EOS;
|
|
379 |
return implode( '|', $ignoredParameters);
|
380 |
}
|
381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
/**
|
383 |
* Get the Generate Session
|
384 |
*
|
@@ -406,8 +414,8 @@ EOS;
|
|
406 |
* @return string
|
407 |
*/
|
408 |
protected function _getGenerateSession() {
|
409 |
-
return Mage::
|
410 |
-
? '
|
411 |
}
|
412 |
|
413 |
|
@@ -825,6 +833,92 @@ EOS;
|
|
825 |
'turpentine_vcl/normalization/cookie_regex' ) );
|
826 |
}
|
827 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
828 |
/**
|
829 |
* Build the list of template variables to apply to the VCL template
|
830 |
*
|
@@ -844,6 +938,7 @@ EOS;
|
|
844 |
'default_ttl' => $this->_getDefaultTtl(),
|
845 |
'enable_get_excludes' => ($this->_getGetParamExcludes() ? 'true' : 'false'),
|
846 |
'enable_get_ignored' => ($this->_getIgnoreGetParameters() ? 'true' : 'false'),
|
|
|
847 |
'debug_headers' => $this->_getEnableDebugHeaders(),
|
848 |
'grace_period' => $this->_getGracePeriod(),
|
849 |
'force_cache_static' => $this->_getForceCacheStatic(),
|
@@ -894,6 +989,13 @@ EOS;
|
|
894 |
$vars['normalize_cookie_target'] = $this->_getNormalizeCookieTarget();
|
895 |
}
|
896 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
897 |
$customIncludeFile = $this->_getCustomIncludeFilename();
|
898 |
if( is_readable( $customIncludeFile ) ) {
|
899 |
$vars['custom_vcl_include'] = file_get_contents( $customIncludeFile );
|
379 |
return implode( '|', $ignoredParameters);
|
380 |
}
|
381 |
|
382 |
+
/**
|
383 |
+
* @return boolean
|
384 |
+
*/
|
385 |
+
protected function _sendUnModifiedUrlToBackend()
|
386 |
+
{
|
387 |
+
return Mage::getStoreConfigFlag('turpentine_vcl/params/transfer_unmodified_url');
|
388 |
+
}
|
389 |
+
|
390 |
/**
|
391 |
* Get the Generate Session
|
392 |
*
|
414 |
* @return string
|
415 |
*/
|
416 |
protected function _getGenerateSession() {
|
417 |
+
return Mage::getStoreConfigFlag( 'turpentine_varnish/general/vcl_fix' )
|
418 |
+
? 'return (pipe);' : 'call generate_session;';
|
419 |
}
|
420 |
|
421 |
|
833 |
'turpentine_vcl/normalization/cookie_regex' ) );
|
834 |
}
|
835 |
|
836 |
+
/**
|
837 |
+
* Get the allowed IPs when in maintenance mode
|
838 |
+
*
|
839 |
+
* @return string
|
840 |
+
*/
|
841 |
+
protected function _vcl_sub_maintenance_allowed_ips() {
|
842 |
+
if((! $this->_getDebugIps()) || ! Mage::getStoreConfig( 'turpentine_vcl/maintenance/custom_vcl_synth' ) ) {
|
843 |
+
return false;
|
844 |
+
}
|
845 |
+
|
846 |
+
switch(Mage::getStoreConfig( 'turpentine_varnish/servers/version' )) {
|
847 |
+
case 4.0:
|
848 |
+
$tpl = <<<EOS
|
849 |
+
if (req.http.X-Forwarded-For) {
|
850 |
+
if (req.http.X-Forwarded-For !~ "{{debug_ips}}") {
|
851 |
+
return (synth(999, "Maintenance mode"));
|
852 |
+
}
|
853 |
+
}
|
854 |
+
else {
|
855 |
+
if (client.ip !~ debug_acl) {
|
856 |
+
return (synth(999, "Maintenance mode"));
|
857 |
+
}
|
858 |
+
}
|
859 |
+
|
860 |
+
EOS;
|
861 |
+
break;
|
862 |
+
default:
|
863 |
+
$tpl = <<<EOS
|
864 |
+
if (req.http.X-Forwarded-For) {
|
865 |
+
if(req.http.X-Forwarded-For !~ "{{debug_ips}}") {
|
866 |
+
error 503;
|
867 |
+
}
|
868 |
+
} else {
|
869 |
+
if (client.ip !~ debug_acl) {
|
870 |
+
error 503;
|
871 |
+
}
|
872 |
+
}
|
873 |
+
EOS;
|
874 |
+
}
|
875 |
+
|
876 |
+
return $this->_formatTemplate( $tpl, array(
|
877 |
+
'debug_ips' => Mage::getStoreConfig( 'dev/restrict/allow_ips' ) ) );
|
878 |
+
}
|
879 |
+
|
880 |
+
/**
|
881 |
+
* Get the allowed IPs when in maintenance mode
|
882 |
+
*
|
883 |
+
* @return string
|
884 |
+
*/
|
885 |
+
protected function _vcl_sub_synth()
|
886 |
+
{
|
887 |
+
if ((!$this->_getDebugIps()) || !Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')) {
|
888 |
+
return false;
|
889 |
+
}
|
890 |
+
|
891 |
+
switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
|
892 |
+
case 4.0:
|
893 |
+
$tpl = <<<EOS
|
894 |
+
sub vcl_synth {
|
895 |
+
if (resp.status == 999) {
|
896 |
+
set resp.status = 404;
|
897 |
+
set resp.http.Content-Type = "text/html; charset=utf-8";
|
898 |
+
synthetic({"{{vcl_synth_content}}"});
|
899 |
+
return (deliver);
|
900 |
+
}
|
901 |
+
return (deliver);
|
902 |
+
}
|
903 |
+
|
904 |
+
EOS;
|
905 |
+
break;
|
906 |
+
default:
|
907 |
+
$tpl = <<<EOS
|
908 |
+
sub vcl_error {
|
909 |
+
set obj.http.Content-Type = "text/html; charset=utf-8";
|
910 |
+
synthetic {"{{vcl_synth_content}}"};
|
911 |
+
return (deliver);
|
912 |
+
}
|
913 |
+
EOS;
|
914 |
+
}
|
915 |
+
|
916 |
+
return $this->_formatTemplate($tpl, array(
|
917 |
+
'vcl_synth_content' => Mage::getStoreConfig('turpentine_vcl/maintenance/custom_vcl_synth')));
|
918 |
+
}
|
919 |
+
|
920 |
+
|
921 |
+
|
922 |
/**
|
923 |
* Build the list of template variables to apply to the VCL template
|
924 |
*
|
938 |
'default_ttl' => $this->_getDefaultTtl(),
|
939 |
'enable_get_excludes' => ($this->_getGetParamExcludes() ? 'true' : 'false'),
|
940 |
'enable_get_ignored' => ($this->_getIgnoreGetParameters() ? 'true' : 'false'),
|
941 |
+
'send_unmodified_url' => ($this->_sendUnModifiedUrlToBackend() ? 'true' : 'false'),
|
942 |
'debug_headers' => $this->_getEnableDebugHeaders(),
|
943 |
'grace_period' => $this->_getGracePeriod(),
|
944 |
'force_cache_static' => $this->_getForceCacheStatic(),
|
989 |
$vars['normalize_cookie_target'] = $this->_getNormalizeCookieTarget();
|
990 |
}
|
991 |
|
992 |
+
if( Mage::getStoreConfig( 'turpentine_vcl/maintenance/enable' ) ) {
|
993 |
+
// in vcl_recv set the allowed IPs otherwise load the vcl_error (v3)/vcl_synth (v4)
|
994 |
+
$vars['maintenance_allowed_ips'] = $this->_vcl_sub_maintenance_allowed_ips();
|
995 |
+
// set the vcl_error from Magento database
|
996 |
+
$vars['vcl_synth'] = $this->_vcl_sub_synth();
|
997 |
+
}
|
998 |
+
|
999 |
$customIncludeFile = $this->_getCustomIncludeFilename();
|
1000 |
if( is_readable( $customIncludeFile ) ) {
|
1001 |
$vars['custom_vcl_include'] = file_get_contents( $customIncludeFile );
|
app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php
CHANGED
@@ -183,9 +183,6 @@ class Nexcessnet_Turpentine_EsiController extends Mage_Core_Controller_Front_Act
|
|
183 |
}
|
184 |
}
|
185 |
$layout = Mage::getSingleton( 'core/layout' );
|
186 |
-
Mage::getSingleton( 'core/design_package' )
|
187 |
-
->setPackageName( $esiData->getDesignPackage() )
|
188 |
-
->setTheme( $esiData->getDesignTheme() );
|
189 |
|
190 |
// dispatch event for adding handles to layout update
|
191 |
Mage::dispatchEvent(
|
183 |
}
|
184 |
}
|
185 |
$layout = Mage::getSingleton( 'core/layout' );
|
|
|
|
|
|
|
186 |
|
187 |
// dispatch event for adding handles to layout update
|
188 |
Mage::dispatchEvent(
|
app/code/community/Nexcessnet/Turpentine/etc/config.xml
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
-
<version>0.6.
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
@@ -80,6 +80,7 @@
|
|
80 |
<params>
|
81 |
<get_params>__SID,XDEBUG_PROFILE</get_params>
|
82 |
<ignore_get_params>utm_source,utm_medium,utm_campaign,utm_content,utm_term,gclid,cx,ie,cof,siteurl</ignore_get_params>
|
|
|
83 |
</params>
|
84 |
<static>
|
85 |
<force_static>1</force_static>
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
+
<version>0.6.7</version>
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
80 |
<params>
|
81 |
<get_params>__SID,XDEBUG_PROFILE</get_params>
|
82 |
<ignore_get_params>utm_source,utm_medium,utm_campaign,utm_content,utm_term,gclid,cx,ie,cof,siteurl</ignore_get_params>
|
83 |
+
<transfer_unmodified_url>0</transfer_unmodified_url>
|
84 |
</params>
|
85 |
<static>
|
86 |
<force_static>1</force_static>
|
app/code/community/Nexcessnet/Turpentine/etc/config.xml~
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
-
<version>0.6.
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
@@ -80,6 +80,7 @@
|
|
80 |
<params>
|
81 |
<get_params>__SID,XDEBUG_PROFILE</get_params>
|
82 |
<ignore_get_params>utm_source,utm_medium,utm_campaign,utm_content,utm_term,gclid,cx,ie,cof,siteurl</ignore_get_params>
|
|
|
83 |
</params>
|
84 |
<static>
|
85 |
<force_static>1</force_static>
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
+
<version>0.6.6</version>
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
80 |
<params>
|
81 |
<get_params>__SID,XDEBUG_PROFILE</get_params>
|
82 |
<ignore_get_params>utm_source,utm_medium,utm_campaign,utm_content,utm_term,gclid,cx,ie,cof,siteurl</ignore_get_params>
|
83 |
+
<transfer_unmodified_url>0</transfer_unmodified_url>
|
84 |
</params>
|
85 |
<static>
|
86 |
<force_static>1</force_static>
|
app/code/community/Nexcessnet/Turpentine/etc/system.xml
CHANGED
@@ -541,6 +541,20 @@
|
|
541 |
<show_in_website>0</show_in_website>
|
542 |
<show_in_store>0</show_in_store>
|
543 |
</ignore_get_params>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
</fields>
|
545 |
</params>
|
546 |
<static translate="label" module="turpentine">
|
@@ -575,6 +589,35 @@
|
|
575 |
</exts>
|
576 |
</fields>
|
577 |
</static>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
</groups>
|
579 |
</turpentine_vcl>
|
580 |
</sections>
|
541 |
<show_in_website>0</show_in_website>
|
542 |
<show_in_store>0</show_in_store>
|
543 |
</ignore_get_params>
|
544 |
+
<transfer_unmodified_url translate="label" module="turpentine">
|
545 |
+
<label>Transfer unmodified URL to Backend Server</label>
|
546 |
+
<comment>
|
547 |
+
By default the backend server (webserver / magento) gets a modified URL (without ignored get parameters).
|
548 |
+
As a result the ignored parameters can not be used by the backend server for uncachable requests, for example a redirect.
|
549 |
+
By activating this option the backend server gets the the unmodified url, but the cache still uses the modified url for lookups.
|
550 |
+
</comment>
|
551 |
+
<frontend_type>select</frontend_type>
|
552 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
553 |
+
<sort_order>21</sort_order>
|
554 |
+
<show_in_default>1</show_in_default>
|
555 |
+
<show_in_website>0</show_in_website>
|
556 |
+
<show_in_store>0</show_in_store>
|
557 |
+
</transfer_unmodified_url>
|
558 |
</fields>
|
559 |
</params>
|
560 |
<static translate="label" module="turpentine">
|
589 |
</exts>
|
590 |
</fields>
|
591 |
</static>
|
592 |
+
<maintenance translate="label" module="turpentine">
|
593 |
+
<label>Maintenance mode</label>
|
594 |
+
<frontend_type>text</frontend_type>
|
595 |
+
<sort_order>46</sort_order>
|
596 |
+
<show_in_default>1</show_in_default>
|
597 |
+
<show_in_website>0</show_in_website>
|
598 |
+
<show_in_store>0</show_in_store>
|
599 |
+
<fields>
|
600 |
+
<enable translate="label" module="turpentine">
|
601 |
+
<label>Enable Maintenance Mode</label>
|
602 |
+
<frontend_type>select</frontend_type>
|
603 |
+
<source_model>turpentine/config_select_toggle</source_model>
|
604 |
+
<comment>If enabled IP's not in 'developer client restrictions' will receive the following error page</comment>
|
605 |
+
<sort_order>10</sort_order>
|
606 |
+
<show_in_default>1</show_in_default>
|
607 |
+
<show_in_website>0</show_in_website>
|
608 |
+
<show_in_store>0</show_in_store>
|
609 |
+
</enable>
|
610 |
+
<custom_vcl_synth translate="label" module="turpentine">
|
611 |
+
<label>Custom HTML content of vcl synth (error) sub</label>
|
612 |
+
<frontend_type>textarea</frontend_type>
|
613 |
+
<comment>Enter full HTML page content</comment>
|
614 |
+
<sort_order>20</sort_order>
|
615 |
+
<show_in_default>1</show_in_default>
|
616 |
+
<show_in_website>0</show_in_website>
|
617 |
+
<show_in_store>0</show_in_store>
|
618 |
+
</custom_vcl_synth>
|
619 |
+
</fields>
|
620 |
+
</maintenance>
|
621 |
</groups>
|
622 |
</turpentine_vcl>
|
623 |
</sections>
|
app/code/community/Nexcessnet/Turpentine/misc/version-2.vcl
CHANGED
@@ -104,6 +104,13 @@ sub vcl_recv {
|
|
104 |
set req.http.X-Opt-Enable-Caching = "{{enable_caching}}";
|
105 |
set req.http.X-Opt-Force-Static-Caching = "{{force_cache_static}}";
|
106 |
set req.http.X-Opt-Enable-Get-Excludes = "{{enable_get_excludes}}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
# Normalize request data before potentially sending things off to the
|
109 |
# backend. This ensures all request types get the same information, most
|
@@ -200,7 +207,14 @@ sub vcl_recv {
|
|
200 |
set req.url = regsuball(req.url, "(?:(\?)?|&)(?:{{get_param_ignored}})=[^&]+", "\1");
|
201 |
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
|
202 |
}
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
|
205 |
return (lookup);
|
206 |
}
|
@@ -220,6 +234,13 @@ sub vcl_pipe {
|
|
220 |
# }
|
221 |
|
222 |
sub vcl_hash {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
set req.hash += req.url;
|
224 |
if (req.http.Host) {
|
225 |
set req.hash += req.http.Host;
|
104 |
set req.http.X-Opt-Enable-Caching = "{{enable_caching}}";
|
105 |
set req.http.X-Opt-Force-Static-Caching = "{{force_cache_static}}";
|
106 |
set req.http.X-Opt-Enable-Get-Excludes = "{{enable_get_excludes}}";
|
107 |
+
set req.http.X-Opt-Send-Unmodified-Url = "{{send_unmodified_url}}";
|
108 |
+
|
109 |
+
|
110 |
+
if(req.http.X-Opt-Send-Unmodified-Url == "true") {
|
111 |
+
# save unmodified url
|
112 |
+
set req.http.X-Varnish-Origin-Url = req.url;
|
113 |
+
}
|
114 |
|
115 |
# Normalize request data before potentially sending things off to the
|
116 |
# backend. This ensures all request types get the same information, most
|
207 |
set req.url = regsuball(req.url, "(?:(\?)?|&)(?:{{get_param_ignored}})=[^&]+", "\1");
|
208 |
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
|
209 |
}
|
210 |
+
|
211 |
+
|
212 |
+
if(req.http.X-Opt-Send-Unmodified-Url == "true") {
|
213 |
+
# change req.url back and save the modified for cache look-ups in a separate variable
|
214 |
+
set req.http.X-Varnish-Cache-Url = req.url;
|
215 |
+
set req.url = req.http.X-Varnish-Origin-Url;
|
216 |
+
unset req.http.X-Varnish-Origin-Url;
|
217 |
+
}
|
218 |
|
219 |
return (lookup);
|
220 |
}
|
234 |
# }
|
235 |
|
236 |
sub vcl_hash {
|
237 |
+
|
238 |
+
if({{send_unmodified_url}} && req.http.X-Varnish-Cache-Url) {
|
239 |
+
set req.hash += req.http.X-Varnish-Cache-Url;
|
240 |
+
} else {
|
241 |
+
set req.hash += req.url;
|
242 |
+
}
|
243 |
+
|
244 |
set req.hash += req.url;
|
245 |
if (req.http.Host) {
|
246 |
set req.hash += req.http.Host;
|
app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl
CHANGED
@@ -97,6 +97,8 @@ sub generate_session_expires {
|
|
97 |
## Varnish Subroutines
|
98 |
|
99 |
sub vcl_recv {
|
|
|
|
|
100 |
# this always needs to be done so it's up at the top
|
101 |
if (req.restarts == 0) {
|
102 |
if (req.http.X-Forwarded-For) {
|
@@ -107,6 +109,11 @@ sub vcl_recv {
|
|
107 |
}
|
108 |
}
|
109 |
|
|
|
|
|
|
|
|
|
|
|
110 |
# Normalize request data before potentially sending things off to the
|
111 |
# backend. This ensures all request types get the same information, most
|
112 |
# notably POST requests getting a normalized user agent string to empower
|
@@ -170,8 +177,7 @@ sub vcl_recv {
|
|
170 |
set req.http.Cookie = "frontend=crawler-session";
|
171 |
} else {
|
172 |
# it's a real user, make up a new session for them
|
173 |
-
{{generate_session}}
|
174 |
-
return (pipe);
|
175 |
}
|
176 |
}
|
177 |
if ({{force_cache_static}} &&
|
@@ -202,6 +208,11 @@ sub vcl_recv {
|
|
202 |
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
|
203 |
}
|
204 |
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
# everything else checks out, try and pull from the cache
|
207 |
return (lookup);
|
@@ -222,7 +233,12 @@ sub vcl_pipe {
|
|
222 |
# }
|
223 |
|
224 |
sub vcl_hash {
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
226 |
if (req.http.Host) {
|
227 |
hash_data(req.http.Host);
|
228 |
} else {
|
@@ -350,6 +366,8 @@ sub vcl_fetch {
|
|
350 |
# else it's not part of Magento so use the default Varnish handling
|
351 |
}
|
352 |
|
|
|
|
|
353 |
sub vcl_deliver {
|
354 |
if (req.http.X-Varnish-Faked-Session) {
|
355 |
# need to set the set-cookie header since we just made it out of thin air
|
97 |
## Varnish Subroutines
|
98 |
|
99 |
sub vcl_recv {
|
100 |
+
{{maintenance_allowed_ips}}
|
101 |
+
|
102 |
# this always needs to be done so it's up at the top
|
103 |
if (req.restarts == 0) {
|
104 |
if (req.http.X-Forwarded-For) {
|
109 |
}
|
110 |
}
|
111 |
|
112 |
+
if({{send_unmodified_url}}) {
|
113 |
+
# save the unmodified url
|
114 |
+
set req.http.X-Varnish-Origin-Url = req.url;
|
115 |
+
}
|
116 |
+
|
117 |
# Normalize request data before potentially sending things off to the
|
118 |
# backend. This ensures all request types get the same information, most
|
119 |
# notably POST requests getting a normalized user agent string to empower
|
177 |
set req.http.Cookie = "frontend=crawler-session";
|
178 |
} else {
|
179 |
# it's a real user, make up a new session for them
|
180 |
+
{{generate_session}}
|
|
|
181 |
}
|
182 |
}
|
183 |
if ({{force_cache_static}} &&
|
208 |
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
|
209 |
}
|
210 |
|
211 |
+
if({{send_unmodified_url}}) {
|
212 |
+
set req.http.X-Varnish-Cache-Url = req.url;
|
213 |
+
set req.url = req.http.X-Varnish-Origin-Url;
|
214 |
+
unset req.http.X-Varnish-Origin-Url;
|
215 |
+
}
|
216 |
|
217 |
# everything else checks out, try and pull from the cache
|
218 |
return (lookup);
|
233 |
# }
|
234 |
|
235 |
sub vcl_hash {
|
236 |
+
|
237 |
+
if({{send_unmodified_url}} && req.http.X-Varnish-Cache-Url) {
|
238 |
+
hash_data(req.http.X-Varnish-Cache-Url);
|
239 |
+
} else {
|
240 |
+
hash_data(req.url);
|
241 |
+
}
|
242 |
if (req.http.Host) {
|
243 |
hash_data(req.http.Host);
|
244 |
} else {
|
366 |
# else it's not part of Magento so use the default Varnish handling
|
367 |
}
|
368 |
|
369 |
+
{{vcl_synth}}
|
370 |
+
|
371 |
sub vcl_deliver {
|
372 |
if (req.http.X-Varnish-Faked-Session) {
|
373 |
# need to set the set-cookie header since we just made it out of thin air
|
app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl
CHANGED
@@ -16,12 +16,12 @@ vcl 4.0;
|
|
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
|
20 |
|
21 |
## Custom C Code
|
22 |
|
23 |
C{
|
24 |
-
|
25 |
{{custom_c_code}}
|
26 |
}C
|
27 |
|
@@ -102,6 +102,8 @@ sub generate_session_expires {
|
|
102 |
## Varnish Subroutines
|
103 |
|
104 |
sub vcl_recv {
|
|
|
|
|
105 |
# this always needs to be done so it's up at the top
|
106 |
if (req.restarts == 0) {
|
107 |
if (req.http.X-Forwarded-For) {
|
@@ -121,6 +123,11 @@ sub vcl_recv {
|
|
121 |
return (pipe);
|
122 |
}
|
123 |
|
|
|
|
|
|
|
|
|
|
|
124 |
# remove double slashes from the URL, for higher cache hit rate
|
125 |
set req.url = regsuball(req.url, "(.*)//+(.*)", "\1/\2");
|
126 |
|
@@ -168,8 +175,7 @@ sub vcl_recv {
|
|
168 |
set req.http.Cookie = "frontend=crawler-session";
|
169 |
} else {
|
170 |
# it's a real user, make up a new session for them
|
171 |
-
{{generate_session}}
|
172 |
-
return (pipe);
|
173 |
}
|
174 |
}
|
175 |
if ({{force_cache_static}} &&
|
@@ -206,6 +212,12 @@ sub vcl_recv {
|
|
206 |
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
|
207 |
}
|
208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
# everything else checks out, try and pull from the cache
|
210 |
return (hash);
|
211 |
}
|
@@ -225,7 +237,13 @@ sub vcl_pipe {
|
|
225 |
# }
|
226 |
|
227 |
sub vcl_hash {
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
if (req.http.Host) {
|
230 |
hash_data(req.http.Host);
|
231 |
} else {
|
@@ -350,6 +368,8 @@ sub vcl_backend_response {
|
|
350 |
# else it's not part of Magento so use the default Varnish handling
|
351 |
}
|
352 |
|
|
|
|
|
353 |
sub vcl_deliver {
|
354 |
if (req.http.X-Varnish-Faked-Session) {
|
355 |
# need to set the set-cookie header since we just made it out of thin air
|
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 |
|
102 |
## Varnish Subroutines
|
103 |
|
104 |
sub vcl_recv {
|
105 |
+
{{maintenance_allowed_ips}}
|
106 |
+
|
107 |
# this always needs to be done so it's up at the top
|
108 |
if (req.restarts == 0) {
|
109 |
if (req.http.X-Forwarded-For) {
|
123 |
return (pipe);
|
124 |
}
|
125 |
|
126 |
+
if({{send_unmodified_url}}) {
|
127 |
+
# save the unmodified url
|
128 |
+
set req.http.X-Varnish-Origin-Url = req.url;
|
129 |
+
}
|
130 |
+
|
131 |
# remove double slashes from the URL, for higher cache hit rate
|
132 |
set req.url = regsuball(req.url, "(.*)//+(.*)", "\1/\2");
|
133 |
|
175 |
set req.http.Cookie = "frontend=crawler-session";
|
176 |
} else {
|
177 |
# it's a real user, make up a new session for them
|
178 |
+
{{generate_session}}
|
|
|
179 |
}
|
180 |
}
|
181 |
if ({{force_cache_static}} &&
|
212 |
set req.url = regsuball(req.url, "(?:(\?)&|\?$)", "\1");
|
213 |
}
|
214 |
|
215 |
+
if({{send_unmodified_url}}) {
|
216 |
+
set req.http.X-Varnish-Cache-Url = req.url;
|
217 |
+
set req.url = req.http.X-Varnish-Origin-Url;
|
218 |
+
unset req.http.X-Varnish-Origin-Url;
|
219 |
+
}
|
220 |
+
|
221 |
# everything else checks out, try and pull from the cache
|
222 |
return (hash);
|
223 |
}
|
237 |
# }
|
238 |
|
239 |
sub vcl_hash {
|
240 |
+
|
241 |
+
if({{send_unmodified_url}} && req.http.X-Varnish-Cache-Url) {
|
242 |
+
hash_data(req.http.X-Varnish-Cache-Url);
|
243 |
+
} else {
|
244 |
+
hash_data(req.url);
|
245 |
+
}
|
246 |
+
|
247 |
if (req.http.Host) {
|
248 |
hash_data(req.http.Host);
|
249 |
} else {
|
368 |
# else it's not part of Magento so use the default Varnish handling
|
369 |
}
|
370 |
|
371 |
+
{{vcl_synth}}
|
372 |
+
|
373 |
sub vcl_deliver {
|
374 |
if (req.http.X-Varnish-Faked-Session) {
|
375 |
# need to set the set-cookie header since we just made it out of thin air
|
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>11:51:06</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>c5e7ba20e9d703f3e6832850d90d9479ee0aa19f</__commit_hash><version>0.6.7</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="45405f2d1c0b5e915ffbd7da261d7ed0" name="turpentine_esi.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="50798888953fd1550e4347c39e395d0a" name="notices.phtml" /><file hash="b268c48251ccfccf5c775d3e85513584" name="esi.phtml" /><file hash="02f341fdfd5194752e88cae9933cfcdb" 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="Helper"><file hash="7934848bff8108cfc67e34e0571bd271" name="Esi.php" /><file hash="802e269b0c80131efbb070309fdc610f" name="Varnish.php" /><file hash="913d0762f9df7696f1217f82791f1b78" name="Cron.php" /><file hash="0ee525f0fba5236f05ad2289fe2f2292" name="Data.php" /><file hash="6b637be4eac4c924fc1f02b2d49699c3" name="Ban.php" /><file hash="4a448ad2fe5b5a253a37d3f4aa3dd1bb" name="Debug.php" /></dir><dir name="misc"><file hash="05abb0bc318ae439f3a6bf53ba11f32a" name="version-3.vcl" /><file hash="1f3a0abeea9acb6d2ec33839dc82012c" name="version-4.vcl" /><file hash="ba5d5c7263cd90eea3785953e3549041" name="uuid.c" /><file hash="af0bd785669e738819536bb806a7ba13" name="version-2.vcl" /></dir><dir name="etc"><file hash="015d30af2e06ffae50e92291592be6d8" name="system.xml" /><file hash="db67350fe497dcb4482f47e297c349f7" name="config.xml~" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /><file hash="2a4bc61f3c6c68fc970707f8828f4046" name="config.xml" /></dir><dir name="controllers"><file hash="c871a1b17344f7e1e267a614bd8e7d5e" name="EsiController.php" /><dir name="Adminhtml"><file hash="fb44492ff908e0dd28a4fa62e382bd3e" name="CacheController.php" /></dir><dir name="Varnish"><file hash="625118bfe342139b7fd9464c05d1b0a6" name="ManagementController.php" /></dir></dir><dir name="Model"><file hash="c2cb79001524617febbfddf099d09f37" name="Session.php" /><dir name="Shim"><dir name="Mage"><dir name="Core"><file hash="9e5d87f0aa84c9fb1541db83aba69abd" name="Config.php" /><file hash="821bff6c2fb372e3ffb39abf6453b3f8" name="Layout.php" /><file hash="4a1aa246373520936f0e4b5b3a3baf25" name="App.php" /></dir></dir></dir><dir name="PageCache"><dir name="Container"><file hash="139e8a9bfa209316036e798fff654a8a" name="Notices.php" /></dir></dir><dir name="Dummy"><file hash="f6611808da53ffa00561a8f76b26016e" name="Request.php" /></dir><dir name="Varnish"><file hash="d174c8dc29d3c4ab34ac0ee57f519d76" name="Admin.php" /><dir name="Admin"><file hash="69828f635e7ce3378fb9aaf861be0b3c" name="Socket.php" /></dir><dir name="Configurator"><file hash="b831b872fcb05d9c723149159db0eed1" name="Version2.php" /><file hash="82d0abe0123272e59e6c319dfdd4e9dc" name="Version3.php" /><file hash="179b9529f2eef55964d25e56b85291a7" name="Version4.php" /><file hash="0672d5ca172564bc4e9457fdfc0a5264" name="Abstract.php" /></dir></dir><dir name="Observer"><file hash="bcc39edc7065ad9d94235211b9e940ca" name="Esi.php" /><file hash="7244a8ce600e980d612409595b9b6b9b" name="Varnish.php" /><file hash="a34e79218e8ca1fefad303b9399bda9d" name="Cron.php" /><file hash="e3e1542dfcf56f2353dd62e39cfd3b98" name="Ban.php" /><file hash="9d57fad69ff42b71c66ca26bc3372317" name="Debug.php" /></dir><dir name="Core"><file hash="d4f63abc6d34c923c6e64a522b6fc36e" name="Session.php" /></dir><dir name="Config"><dir name="Select"><file hash="2e01b14592189b3f6a8a05be5ef4c69c" name="StripWhitespace.php" /><file hash="15b5296a7f7bc719331f14d34308013b" name="Version.php" /><file hash="2a4648995fc87472b2ac33b35a7d69e5" name="LoadBalancing.php" /><file hash="9348c5e58037fd97d89b84ccab4ef2d0" name="Toggle.php" /></dir></dir></dir><dir name="Block"><file hash="e9b03d651a8da9b1d32c4fd2f4781792" name="Management.php" /><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><dir name="Adminhtml"><dir name="Cache"><file hash="798cf7afa80e0a06be2b8c6cb2bef02b" name="Grid.php" /></dir></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file hash="ce9fca4c273987759f284fe31c1597f5" name="Toolbar.php" /></dir></dir></dir><dir name="Product"><file hash="56ac2e90d0eed7eaadaf4517c1ad77ff" name="Compared.php" /><file hash="f72d0718ccd2895cbf4fc1cbc24bf90c" name="Viewed.php" /></dir><dir name="Core"><file hash="b34cad980a3e5da9860b21a7aa7a0b0f" name="Messages.php" /></dir><dir name="Poll"><file hash="bf9ca23a445776435e38e6c8be9976ea" name="ActivePoll.php" /></dir></dir></dir></dir></target></contents><dependencies><required><php><min>5.2.13</min><max>6.0.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>2015-10-12</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>
|