Version Notes
Supports Magento v1.6 and later
Download this release
Release Info
Developer | Chris Wells |
Extension | Nexcessnet_Turpentine |
Version | 0.7.0 |
Comparing to | |
See all releases |
Code changes from version 0.6.9 to 0.7.0
- app/code/community/Nexcessnet/Turpentine/Helper/Cron.php +18 -0
- app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php +19 -0
- app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php +30 -28
- app/code/community/Nexcessnet/Turpentine/Model/Observer/Cron.php +15 -0
- app/code/community/Nexcessnet/Turpentine/etc/config.xml +4 -2
- app/code/community/Nexcessnet/Turpentine/etc/system.xml +24 -0
- app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +1 -1
- package.xml +1 -1
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
CHANGED
@@ -145,6 +145,24 @@ class Nexcessnet_Turpentine_Helper_Cron extends Mage_Core_Helper_Abstract {
|
|
145 |
return Mage::getStoreConfig('turpentine_varnish/general/crawler_debug');
|
146 |
}
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
/**
|
149 |
* Get the list of all URLs
|
150 |
*
|
145 |
return Mage::getStoreConfig('turpentine_varnish/general/crawler_debug');
|
146 |
}
|
147 |
|
148 |
+
/**
|
149 |
+
* Get number of urls to crawl per batch
|
150 |
+
*
|
151 |
+
* @return int
|
152 |
+
*/
|
153 |
+
public function getCrawlerBatchSize() {
|
154 |
+
return Mage::getStoreConfig('turpentine_varnish/general/crawler_batchsize');
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Get time in seconds to wait between url batches
|
159 |
+
*
|
160 |
+
* @return int
|
161 |
+
*/
|
162 |
+
public function getCrawlerWaitPeriod() {
|
163 |
+
return Mage::getStoreConfig('turpentine_varnish/general/crawler_batchwait');
|
164 |
+
}
|
165 |
+
|
166 |
/**
|
167 |
* Get the list of all URLs
|
168 |
*
|
app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php
CHANGED
@@ -50,4 +50,23 @@ class Nexcessnet_Turpentine_Model_Core_Session extends Mage_Core_Model_Session
|
|
50 |
}
|
51 |
return $this->getData('_form_key');
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
50 |
}
|
51 |
return $this->getData('_form_key');
|
52 |
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Creates new Form key
|
56 |
+
*/
|
57 |
+
public function renewFormKey()
|
58 |
+
{
|
59 |
+
$this->setData('_form_key', Mage::helper('core')->getRandomString(16));
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Validates Form key
|
64 |
+
*
|
65 |
+
* @param string|null $formKey
|
66 |
+
* @return bool
|
67 |
+
*/
|
68 |
+
public function validateFormKey($formKey)
|
69 |
+
{
|
70 |
+
return ($formKey === $this->getFormKey());
|
71 |
+
}
|
72 |
}
|
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
CHANGED
@@ -298,37 +298,39 @@ class Nexcessnet_Turpentine_Model_Observer_Ban extends Varien_Event_Observer {
|
|
298 |
* @return bool
|
299 |
*/
|
300 |
public function banProductReview($eventObject) {
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
|
|
309 |
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
|
|
322 |
}
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
$urlPattern = implode('|', $patterns);
|
329 |
|
330 |
-
|
331 |
-
|
|
|
332 |
}
|
333 |
|
334 |
/**
|
298 |
* @return bool
|
299 |
*/
|
300 |
public function banProductReview($eventObject) {
|
301 |
+
if (Mage::helper('turpentine/varnish')->getVarnishEnabled()) {
|
302 |
+
$patterns = array();
|
303 |
+
/* @var $review \Mage_Review_Model_Review*/
|
304 |
+
$review = $eventObject->getObject();
|
305 |
+
|
306 |
+
/* @var $productCollection \Mage_Review_Model_Resource_Review_Product_Collection*/
|
307 |
+
$productCollection = $review->getProductCollection();
|
308 |
+
|
309 |
+
$products = $productCollection->addEntityFilter((int) $review->getEntityPkValue())->getItems();
|
310 |
|
311 |
+
$productIds = array_unique(array_map(
|
312 |
+
create_function('$p', 'return $p->getEntityId();'),
|
313 |
+
$products ));
|
314 |
+
$patterns[] = sprintf('/review/product/list/id/(?:%s)/category/',
|
315 |
+
implode('|', array_unique($productIds)));
|
316 |
+
$patterns[] = sprintf('/review/product/view/id/%d/',
|
317 |
+
$review->getEntityId());
|
318 |
+
$productPatterns = array();
|
319 |
+
foreach ($products as $p) {
|
320 |
+
$urlKey = $p->getUrlModel()->formatUrlKey($p->getName());
|
321 |
+
if ($urlKey) {
|
322 |
+
$productPatterns[] = $urlKey;
|
323 |
+
}
|
324 |
}
|
325 |
+
if ( ! empty($productPatterns)) {
|
326 |
+
$productPatterns = array_unique($productPatterns);
|
327 |
+
$patterns[] = sprintf('(?:%s)', implode('|', $productPatterns));
|
328 |
+
}
|
329 |
+
$urlPattern = implode('|', $patterns);
|
|
|
330 |
|
331 |
+
$result = $this->_getVarnishAdmin()->flushUrl($urlPattern);
|
332 |
+
return $this->_checkResult($result);
|
333 |
+
}
|
334 |
}
|
335 |
|
336 |
/**
|
app/code/community/Nexcessnet/Turpentine/Model/Observer/Cron.php
CHANGED
@@ -49,6 +49,11 @@ class Nexcessnet_Turpentine_Model_Observer_Cron extends Varien_Event_Observer {
|
|
49 |
if ($maxRunTime === 0) {
|
50 |
$maxRunTime = self::MAX_CRAWL_TIME;
|
51 |
}
|
|
|
|
|
|
|
|
|
|
|
52 |
// just in case we have a silly short max_execution_time
|
53 |
$maxRunTime = abs($maxRunTime - self::EXEC_TIME_BUFFER);
|
54 |
while (($helper->getRunTime() < $maxRunTime) &&
|
@@ -57,6 +62,16 @@ class Nexcessnet_Turpentine_Model_Observer_Cron extends Varien_Event_Observer {
|
|
57 |
Mage::helper('turpentine/debug')->logWarn(
|
58 |
'Failed to crawl URL: %s', $url );
|
59 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
}
|
62 |
}
|
49 |
if ($maxRunTime === 0) {
|
50 |
$maxRunTime = self::MAX_CRAWL_TIME;
|
51 |
}
|
52 |
+
|
53 |
+
$batchSize = $helper->getCrawlerBatchSize();
|
54 |
+
$timeout = $helper->getCrawlerWaitPeriod();
|
55 |
+
$crawlCount = 0;
|
56 |
+
|
57 |
// just in case we have a silly short max_execution_time
|
58 |
$maxRunTime = abs($maxRunTime - self::EXEC_TIME_BUFFER);
|
59 |
while (($helper->getRunTime() < $maxRunTime) &&
|
62 |
Mage::helper('turpentine/debug')->logWarn(
|
63 |
'Failed to crawl URL: %s', $url );
|
64 |
}
|
65 |
+
|
66 |
+
if ($crawlCount > 0
|
67 |
+
&& $timeout > 0
|
68 |
+
&& $batchSize > 0
|
69 |
+
&& $crawlCount % $batchSize == 0
|
70 |
+
) {
|
71 |
+
Mage::helper('turpentine/debug')->logDebug('Crawled '.$crawlCount.' urls, sleeping for '.$timeout.' seconds');
|
72 |
+
sleep($timeout);
|
73 |
+
}
|
74 |
+
$crawlCount++;
|
75 |
}
|
76 |
}
|
77 |
}
|
app/code/community/Nexcessnet/Turpentine/etc/config.xml
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
-
<version>0.
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
@@ -35,6 +35,8 @@
|
|
35 |
<fix_product_toolbar>0</fix_product_toolbar>
|
36 |
<crawler_enable>0</crawler_enable>
|
37 |
<crawler_debug>0</crawler_debug>
|
|
|
|
|
38 |
</general>
|
39 |
<logging>
|
40 |
<use_custom_log_file>0</use_custom_log_file>
|
@@ -59,7 +61,7 @@
|
|
59 |
<frontend_timeout>300</frontend_timeout>
|
60 |
<admin_timeout>21600</admin_timeout>
|
61 |
<crawlers>127.0.0.1</crawlers>
|
62 |
-
<crawler_user_agents><![CDATA[ApacheBench/.*,.*Googlebot.*,JoeDog/.*Siege.*,magespeedtest\.com,Nexcessnet_Turpentine
|
63 |
</backend>
|
64 |
<normalization>
|
65 |
<encoding>1</encoding>
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
+
<version>0.7.0</version>
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
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>
|
61 |
<frontend_timeout>300</frontend_timeout>
|
62 |
<admin_timeout>21600</admin_timeout>
|
63 |
<crawlers>127.0.0.1</crawlers>
|
64 |
+
<crawler_user_agents><![CDATA[ApacheBench/.*,.*Googlebot.*,JoeDog/.*Siege.*,magespeedtest\.com,Nexcessnet_Turpentine/.*,.*PTST.*]]></crawler_user_agents>
|
65 |
</backend>
|
66 |
<normalization>
|
67 |
<encoding>1</encoding>
|
app/code/community/Nexcessnet/Turpentine/etc/system.xml
CHANGED
@@ -132,6 +132,30 @@
|
|
132 |
<show_in_website>0</show_in_website>
|
133 |
<show_in_store>0</show_in_store>
|
134 |
</crawler_debug>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
</fields>
|
136 |
</general>
|
137 |
<logging translate="label" module="turpentine">
|
132 |
<show_in_website>0</show_in_website>
|
133 |
<show_in_store>0</show_in_store>
|
134 |
</crawler_debug>
|
135 |
+
<crawler_batchsize translate="label" module="turpentine">
|
136 |
+
<label>Crawler Batch Size</label>
|
137 |
+
<comment>Number of URLs to crawl per batch, when 0 requests will not be batched</comment>
|
138 |
+
<frontend_type>text</frontend_type>
|
139 |
+
<sort_order>90</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>0</show_in_website>
|
142 |
+
<show_in_store>0</show_in_store>
|
143 |
+
<depends>
|
144 |
+
<crawler_enable>1</crawler_enable>
|
145 |
+
</depends>
|
146 |
+
</crawler_batchsize>
|
147 |
+
<crawler_batchwait translate="label" module="turpentine">
|
148 |
+
<label>Crawler Batch Wait</label>
|
149 |
+
<comment>Time in seconds to wait between batches</comment>
|
150 |
+
<frontend_type>text</frontend_type>
|
151 |
+
<sort_order>100</sort_order>
|
152 |
+
<show_in_default>1</show_in_default>
|
153 |
+
<show_in_website>0</show_in_website>
|
154 |
+
<show_in_store>0</show_in_store>
|
155 |
+
<depends>
|
156 |
+
<crawler_enable>1</crawler_enable>
|
157 |
+
</depends>
|
158 |
+
</crawler_batchwait>
|
159 |
</fields>
|
160 |
</general>
|
161 |
<logging translate="label" module="turpentine">
|
app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl
CHANGED
@@ -116,7 +116,7 @@ sub vcl_recv {
|
|
116 |
if (!{{enable_caching}} || req.http.Authorization ||
|
117 |
req.method !~ "^(GET|HEAD|OPTIONS)$" ||
|
118 |
req.http.Cookie ~ "varnish_bypass={{secret_handshake}}") {
|
119 |
-
return (
|
120 |
}
|
121 |
|
122 |
if({{send_unmodified_url}}) {
|
116 |
if (!{{enable_caching}} || req.http.Authorization ||
|
117 |
req.method !~ "^(GET|HEAD|OPTIONS)$" ||
|
118 |
req.http.Cookie ~ "varnish_bypass={{secret_handshake}}") {
|
119 |
+
return (pass);
|
120 |
}
|
121 |
|
122 |
if({{send_unmodified_url}}) {
|
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>10:
|
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:53:41</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>8549a0f207c63e62c61570f81925bd574c63f2c5</__commit_hash><version>0.7.0</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="d121558e4cd5775b0845ebeec5909b97" 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="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="controllers"><file hash="9963ddff7c13d5d087aa3dbdffcd1532" 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="7f156b5d3f3aafd56f8ec67f4d70d436" name="Esi.php" /><file hash="99ec12c46fd42fbfabdb191c4af7fbe6" name="Varnish.php" /><file hash="c1a55b8d3bdb780fcd3315d214e94b01" name="Data.php" /></dir><dir name="misc"><file hash="9c07f16b0d2b692578cc6dab15a11804" name="version-2.vcl" /><file hash="ba5d5c7263cd90eea3785953e3549041" name="uuid.c" /><file hash="f8368123a257cb25ee7db63ec54cce12" name="version-3.vcl" /><file hash="65657268cb1983c0dcc3846570bb8594" name="version-4.vcl" /></dir><dir name="etc"><file hash="f2640ecefaf2af56b62ba48fd9b4a391" name="config.xml" /><file hash="73d441e94f0530357f2c96e27a1442d1" name="system.xml" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /></dir><dir name="Block"><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><file hash="5584baf2ebba7e0fe7e9491a46a6e4cf" name="Management.php" /><dir name="Adminhtml"><dir name="Cache"><file hash="8265061356f8096fc82c88334b4effc9" name="Grid.php" /></dir></dir><dir name="Poll"><file hash="4b64be7088235d85610892b1dfe6f768" 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="b264dc1982cef539b8dc2c86aa34c5c3" name="Admin.php" /><dir name="Configurator"><file hash="870922083925f5120e4ec52f279a8870" name="Version4.php" /><file hash="d4d66168e43a62ceab30226b44b9e98b" name="Version2.php" /><file hash="eea0cbf3c779a9d9ce8b38f33aa7d333" name="Abstract.php" /><file hash="c0c0d52175e72b95c059345a31b5de31" name="Version3.php" /></dir><dir name="Admin"><file hash="304cdb4970dec60460433163d5532533" 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="403dcea1f19b377f30af5f89297d9a69" 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="d92dc22addfd90ed5b929e8cb17b8002" name="Esi.php" /><file hash="16e4975274e8c3454bf2226d5a0558e6" name="Varnish.php" /></dir><dir name="Core"><file hash="8f512da6e6da419acc07710b079e3ca9" 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>2016-05-31</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>
|