GithubHelp home page GithubHelp logo

phoenix-media / magento-pagecache-powered-by-varnish Goto Github PK

View Code? Open in Web Editor NEW
89.0 22.0 49.0 156 KB

Community version which is available on Magento Connect (http://www.magentocommerce.com/magento-connect/pagecache-powered-by-varnish.html)

PHP 81.99% HTML 2.86% Perl 15.15%

magento-pagecache-powered-by-varnish's Introduction

Table of contents

  1. Introduction
  2. Prerequisites
  3. Installation
    3.1 Varnish 4.1
    3.2 Libraries needed
  4. Configuration
    4.1 PageCache module
    4.2 Varnish Cache (VCL)
    4.3 ESI
  5. Cache cleaning, PURGE requests
  6. VCL Design Exceptions
  7. Troubleshooting
    7.1 Known issues
    7.2 Prevent caching for custom modules
    7.3 Prevent caching for HTML/PHP files outside Magento
    7.4 Debugging requests
    7.5 Vary HTTP header for User-Agent
  8. Changelog

1. Introduction

Thank you for using "PageCache powered by Varnish" (PageCache) module. This package contains everything you need to connect Varnish Cache with your Magento Commerce shop and to get the most out of Varnish’s powerful caching capabilities for a blazing fast eCommerce site.

The PageCache module has been architectural certified by Varnish Software to ensure highest quality and reliability for Magento stores. PHOENIX MEDIA is a Varnish Integration Partner and Magento Gold Partner in Germany and Austria and is maintaining this module as well as providing professional services for Varnish and Magento Commerce.

The PageCache module consists of two main components:

  • The Magento module and
  • the bundled Varnish Cache configuration file (VCL).

The PageCache module basically sets the correct Cache-Control headers according to the configuration and the visitor session and provides an interface for cleaning Varnish’s cache. The second component, the VCL, configures Varnish to process the client requests and Magento’s HTML response according to the Cache-Control headers the PageCache module adds to every response.

Beside shop pages Varnish will also cache static content that is served by the web server like product images, CSS or JavaScript files or even flash or PDF resources. While you can also clean Varnish’s static content cache from the Magento Cache Management page the PageCache configuration won’t affect any of the static file’s HTTP headers as they are directly served by the web server.

2. Prerequisites

Before installing the PageCache module you should setup a test hosting environment as you will need to change the web server’s port configuration and put Varnish in front which will certainly take a while for configuring and testing. If you directly rollout this solution to your production server you will certainly have down times which should be prevented to not annoy your customers.

Ensure that your Magento Commerce shop is running without any problems in your environment as debugging Magento issues with a proxy like Varnish in front might be difficult.

PageCache supports Magento Community Edition from version 1.5.1 and Magento Professional/Enterprise Edition from version 1.9.0 on.

Furthermore you should have installed Varnish >= 3.0 on your Linux server. To install Varnish Cache refer to the excellent documentation at http://www.varnish-cache.org/docs/ where you will also find lots of information about VCL (Varnish Configuration Language), the heart of Varnish. If you need professional service for setup your server please contact Varnish Software for commercial support for the Varnish Cache software.

Check out their website or send them a mail at [email protected].

3. Installation

The installation of the Magento module is pretty easy:

  1. Copy the contents of the app directory in the archive to the app directory of your Magento instance.
  2. Go to the Magento backend and open the Cache Management (System → Cache Management) and refresh the configuration and layout cache.

If any critical issue occurs you can’t easily solve, go to app/etc/modules, open Phoenix_VarnishCache.xml and set "false" in the "active" tag to deactivate the PageCache module. If necessary clear Magento’s cache again.

As Varnish is already installed on your server you should just make a backup of your default.vcl file which is shipped with Varnish. It should be located at /etc/varnish/default.vcl. Copy the VCL file bundled with the PageCache module for your version of Varnish (located at app/code/local/Phoenix/VarnishCache/etc/default*.vcl) to your Varnish configuration directory (/etc/varnish/). If you subscribed to the Enterprise Edition of the module you find and improved VCL file with ESI support (see section 4.4) here: app/code/local/Phoenix/VarnishCacheEnterprise/etc/esi_3.0.vcl.

In case you use EE >= 1.13 or CE >= 1.8 and you want to make use of frontend form keys you have to enable ESI within varnish.

We also recommend you check Varnish's startup parameters. Depending on your OS the location of your startup settings might differ.

For RHEL/CentOS e.g. you find it under /etc/sysconfig/varnish.

To make ESI run smoothly add this startup parameters:

-p esi_syntax=0x03

to make varnish not yell at you cause of "no valid XML"

-p shm_reclen=4096

to maximize the length for GET requests - 4K should be fair enough. If this is too short - varnish will truncate your request.

Do not restart the Varnish service until you have checked the new VCL file to adjust your hosting specific values (at least backends and purge ACLs).

Proceed with the configuration.

3.1 Varnish 4.1

Since version 4.3.0 this module supports Varnish 4.1 (4.0.x is not supported due to a bug where ESI-included synthetic response is delivered uncompressed within a gzipped response, see https://www.varnish-cache.org/trac/ticket/1688)

To use varnish 4 you have to install version 4.1 and use the corresponding vcl file included within this module.

To make ESI work with varnish 4 add the following to your startup parameters

-p feature=+esi_disable_xml_check,+esi_ignore_other_elements \

The maximum length for GET requests has also changed and allows a maximum value of 4084

-p vsl_reclen=4084 \

Inline C has to be allowed explicit with

-p vcc_allow_inline_c=on \

3.2 Libraries needed

As of version 4.3.0 the vcl uses OpenSSLs md5 hashing method to generate formkeys, so you have to make sure that openssl-devel package is installed on the server running Varnish.

To make Varnish use the OpenSSL library add the following parameter to the options when starting varnishd

-p 'cc_command=exec cc -fpic -shared -Wl,-x -o %o %s -lcrypto -lssl'

4. Configuration

This section handles the different configuration option for the module as well as settings that have to be done on the server side.

4.1 PageCache module

In your Magento backend go to System → Configuration → "PageCache powered by Varnish Enterprise" and open "General Settings" tab.

In the following section the configuration options for the PageCache powered by Varnish module are explained. Most of them can be changed on website and store view level which allows fine granulated configurations for different store frontends.

Note that if you change a value here Varnish will not reflect it until you purge its HTML objects or the TTL of the cached objects expires.

Enable cache module

This enables the basic functionality like setting HTTP headers and allows cache cleaning on the Magento Cache Management page. This option should be set to "Yes" globally even if you like to deactivate the module for certain websites or store views. Otherwise the cleaning options on the Cache Management page won’t be available.

Varnish servers

Add your Varnish server(s) domains or IPs separated by semicolon.

Server port

The port your Varnish servers listens on.

This port is used for all servers in your server list.

Admin Server port

The port your Varnish servers telnet listens to.

This port is used for all servers in your server list.

Admin server secret

Secret string for CLI authentication.

This file is used for all servers in your server list.

Disable caching

This option allows you to deactivate caching of every Magento frontend page in Varnish. This is useful for development or tests by passing all requests through Varnish without caching them. If you have a staging website within your Magento Enterprise instance make sure this option is set to "Yes" for this website.

Technically Varnish will still be active but every request gets a TTL of 0.

Disable caching for routes

Certain controllers or actions within Magento must not be cached by Varnish as their response surely contains custom data or it is necessary to process a request in database (API calls, payment callbacks). Although Varnish passes all POST requests (which most often are used to submit forms with custom information etc.) you can also define the controllers and actions that should have the "no-cache" flag in their HTTP response header.

Note: The function relies on Mage_Core_Controller_Varien_Action::getFullActionName().

Disable caching vars

Some GET variables in the frontend will not only change a single page but will be stored in the visitor session and change the output of all following request that might not have this GET parameter. For example a store view, language or currency switch will only pass the parameter once to Magento to change the output and all following requests will not contain this parameter in the URL as the information is taken from the visitor’s session.

As Varnish is not session aware it can handle only one content per domain + URL combination. To prevent any conflicts with this behavior the PageCache module will set a NO_CACHE cookie to the response to pass all following request by this client through Varnish and let Magento handle the request directly.

Default cache TTL

Varnish delivers cached objects without requesting the web server or Magento again for a certain period of time defined in the TTL (time to live) value. You can adjust the TTL for your shop pages on store view level which allows you to have different TTLs for your frontend pages. Note that this field only allows numeric values in seconds. It doesn’t support the same notation that can be used in the VCL. "2h" (2 hours) have to be entered as "7200" seconds.

For static contents Varnish uses the default TTL value defined in the vcl_fetch section of the VCL (Default: set beresp.ttl = 4h).

Cache TTL for routes

This options allows you to adjust Varnish cache TTL on a per magento controllers/actions basis. To add a new TTL value for route 1. click "Add route" button 2. input route (e.g. "cms", "catalog_product_view"); 3. input TTL for route in seconds (e.g. "7200").

"Default Cache TTL" value is used when no TTL for a given route is defined.

Export VCL File

When clicked this button, PageCache module reads VCL loaded to RAM, updates it according to Magento Design Exceptions configurations and serves VCL file for download. Varnish servers should be restarted using this file to changes take place.

Purge category

This option binds automatic purge of category (Varnish) cache with its update event. If you always want up-to-date category information on front-end set the option value to "Yes" and category cache will be invalidated each time a category update occurs.

Purge product

This option binds purge of product (Varnish) cache with product and product's stock update. If set to "Yes" product pages cache is invalidated each time product update or product's stock update occurs. Additionally, if "Purge Category" option is set to "Yes" this triggers product's categories cache purge on product/product stock update.

This option is useful to keep product pages and categories up-to-date when product becomes out of stock (i.e. when the last item purchased by a customer).

Purge CMS page

This option binds automatic purge of CMS page (Varnish) cache with its update event. If set to "Yes" CMS page cache is invalidated each time CMS page update event occurs (i.e. CMS page content update via Magento admin).

Debug

The PageCache module adds several HTTP headers to let Varnish know what to do with the Magento response. Also Varnish adds several tags in the HTTP headers to pass information to the client to allow debugging of requests directly in the browser. However this information should be removed in production environments which can easily be done by setting this value to "No".

Beside the HTTP headers the PageCache module can also log purge requests to /var/log/varnish_cache.log if the developer log (System → Configuration → Developer) is enabled. The log file will allow you to see which PURGE requests have been sent to Varnish.

4.2 Varnish Cache (VCL)

PageCache ships with a ready-to-go VCL file that let Magento and Varnish play nicely together. Although the VCL should be sufficient to start with Magento and Varnish right away you can of course adjust it to your needs if necessary. Please see VCL documentation at http://www.varnish-cache.org/docs/3.0/reference/vcl.html.

In the "etc" subdirectory you can find different vcl files:

  • default_3.0.vcl
  • default_4.1.vcl

You have to copy the needed vcl files to your varnish config directory.

When putting Varnish in front of your web server (backend) you will have to change the web server’s port which is normally port 80. We recommend to change its’ listen port to 8080 which is already configured in the VCL. If your Varnish server doesn’t run on the same server as your web server (backend) you need to adjust the default backend at the beginning of the VCL file. Also you will have to adjust the purge ACL below to allow the purge requests which are triggered from the Magento backend which have the IP of your web server (backend).

We also recommend adjusting the vcl_error section which will be echoed if the backend (Magento) is not available.

As special feature Varnish’s saint mode has been enabled in the vcl_fetch section by default, which allows Varnish to deliver content even if an object is expired when your backend is unreachable to refresh it. With this feature your uptime and availability will be increased for better customer experience.

Beside the VCL don't forget to check Varnish's startup parameters. They allow fine tuning of timeouts, cache size, location of the VCL file and much more. Checkout Varnish Cache documentation for details.

4.3 ESI

Edge Side Includes (ESI) is implemented in Varnish as a subset of the W3C definition (http://www.w3.org/TR/esi-lang) and supports esi:include and esi:remove only.

With ESI enabled your Magento installation will become even faster than running only Varnish alone. ESI is used to cache recurring snippets (aka blocks in Magento) and reuse them in different pages.

Please note that the Page Cache shipped with Magento Enterprise Edition is not compatible with ESI and therefore has to be turned of (System → Cache Management) as it is based on the same application logic (replacing original blocks with placeholders and compile the actual page content on the fly).

Form Key Handling

As with version CE 1.8 and EE 1.13 Magento introduced form keys in the frontend.

Form keys are generated by varnish and therefor ESI is always enabled in the vcl files provided with this project.

5. Cache cleaning, PURGE requests

Varnish caches objects for a certain period of time according to their TTL. After that the object will not be requested from the web server or Magento again. Until the TTL expires Varnish will deliver the cached object no matter what will change within Magento or the webserver’s file system. To force Varnish to cleanup its’ cache and to retrieve the information again from the backend you can trigger a purge/ban requests right from Magento.

In the Magento backend go to System→Cache Management. If you have enabled the PageCache module in the configuration you will see a new button "Clean Varnish Cache" in the "Additional Cache Management" section. You can purge all objects in Varnish Cache by just clicking "Clean Varnish Cache" or define which store view and/or content type should be purged. For the store views PageCache will look up the configured domains in System → Configuration → Web and pass the domain(s) of the selected store view as an argument of the purge request to Varnish. This will allow you for example to remove the CSS files of a certain store view in Varnish if they have been modified without the need to invalidate any other object which will save a lot of resources on high frequented stores.

It is also possible to purge a single url (e.g. page) using "Quick Purge". Enter desired URL in input field next to "Quick Purge" button and press it. If URL is valid you'll see a success message for purged page.

Beside these direct purge requests PageCache has observers for "Flush Magento Cache" and "Flush Cache Storage" to purge all objects in Varnish together with the Magento cache refresh. It also has observers for "Flush Catalog Images Cache" and "Flush JavaScript/CSS Cache" to clean objects that match the appropriate URL path in Varnish. All HTML objects will be purged too as the product image and JavaScript/CSS paths will change when Magento generated them again so the cached HTML objects might contain wrong paths if not refreshed. You can also enable automatic purging of CMS pages, categories and products when they are saved (see configuration). If you don’t want these observers to take automatic action comment them out in the config.xml of the PageCache module.

6. VCL Design Exceptions

By default Varnish does not take into account User-Agent string of a request when building its cache object. Magento Design Exceptions use regular expressions to match different design configurations to User-Agent strings. In order to make Design Exceptions work with Varnish you will have to renewVarnish VCL each time Design Exceptions are updated. Here's what you have to do:

  • In your Magento backend go to System → Configuration → "PageCache powered by Varnish Enterprise" and open "General Settings" tab.
  • Press "Export VCL" button.
  • Your browser should start file download your server VCL updated with design exceptions subroutine.
  • Restart your varnish servers using downloaded VCL.

You can run man varnishd in command line for description of varnishd options. Also see documentation explaining how to start varnish for versions 3.0 respectively: https://www.varnish-cache.org/docs/3.0/tutorial/starting_varnish.html

7. Troubleshooting

7.1 Known issues

  • "Use SID in Frontend" in System Configuration → Web → Session Validation Settings must not be set to "yes" otherwise a GET parameter ___SID will be added which disables caching at all.
  • "Redirect to CMS-page if Cookies are Disabled" in System Configuration → Web → Browser Capabilities Detection must be turned off as visitors served by Varnish won't get a cookie until they put something in the cart of login.
  • Logging and statistics will be fragmentary (Varnish won't pass cached requests to the webserver or Magento). Instead make use of a JavaScript based statistics like Google Analytics or contact Varnish Software who offers additional tools for that as part of their subscription services.
  • Running FPC (Magento Enterprise Full Page Cache) along with ESI will result in ESI not displaying any cached blocks. To use Varnish ESI with Magento Enterprise you have to disable FPC completely.

7.2 Prevent caching for custom modules

In your Magento installation you will surely have custom modules whose HTML output shouldn’t be cached. Therefore you have two options:

  • Either add their controllers to the "Disable caching for routes" configuration to prevent caching of their output.
  • Or, if your module changes the visitor session for all following request, dispatch an event in your Magento module and add an observer to let PageCache set a NO_CACHE cookie (compare config.xml):
<catalog_product_compare_add_product>
    <observers>
        <varnishcache>
            <class>varnishcache/observer</class>
            <method>disablePageCachingPermanent</method>
        </varnishcache>
    </observers>
</catalog_product_compare_add_product>

7.3 Prevent caching for HTML/PHP files outside Magento

Varnish as a proxy respects caching information from the backend server like "Cache-Control: max-age=600" or "Expires: Thu, 19 Nov 2021 08:52:00 GMT". PageCache uses "Expires" to tell Varnish whether a Magento page is cacheable and how long.

If you have mod_expires installed in your Apache and the Magento default setting in your .htaccess 'ExpiresDefault "access plus 1 year"' this will allow Varnish to cache every object outside of Magento (e.g. files in js, media or skin folder) for one year. However this also affects HTML or PHP files if they don't set their own "Cache-Control" or "Expires" header. If you don't want HTML contents which don't explicitly allow caching to be cached by Varnish, add this line to the mod_expires section of your .htaccess file:

    ExpiresByType text/html A0

This will set the expiry time of the object equal to the delivery time which will not allow Varnish to cache the object.

Note that if a "Expires" header is already set in the HTTP response header mod_expires will respect it and pass this header without changes.

7.4 Debugging requests

If Varnish does not behave like you expect there are some great tools that will help you to analyze what’s going on. First you should activate the debug mode in the PageCache module and purge the HTML objects in System → Cache Management to pass the full HTTP headers to your browser.

A really great help for debugging requests is the "varnishlog" command that is part of the Varnish distribution.

You can call it on the shell to show only HTML requests:

	varnishlog -c -o TxHeader "Content-Type: text/html" (Varnish 2.1)

Or of a certain URL:

	varnishlog -m RxURL:"^/blog" (Varnish 3.0)

You can also filter the output for a certain client IP:

	varnishlog -c -o ReqStart 123.456.78.9

If you still can’t solve the issues please contact [email protected] to request professional services.

7.5 Vary HTTP header for User-Agent

Some administrators have this line in Magento's .htaccess file:

    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary

However this forces Varnish Cache to have one cache element per user agent string for each URL which makes caching almost useless. If you have the feeling that in one browser your cache is hot while in a different browser the Varnish has no cache hits check your backend response with varnishlog and make sure the Vary header only looks like this:

    Vary: Accept-Encoding

8. Changelog

4.4.0

  • added header check for varnish to signal esi capability
  • added vcl for Varnish 4.1

4.3.0

  • new formkey generation based on request data
  • esi data lookup now uses regex

4.2.8

  • improved environment hashing

4.2.7

  • fixed geoip handling fallback

4.2.6

  • removed sid from redirect url in geo ip

4.2.5

  • added country code lookup
  • country mapping is now case insensitive

4.2.4

  • changed block names for geoip esi tags

4.2.3

  • added option to disable ESI over HTTPS (#16)

4.2.2

  • fixed issue #6 by setting DoEsi header when form_keys are replaced to enable ESI processing in VCL
  • fixed error in translation (#12)

4.2.1

  • fixed issue post requests and form keys

4.2.0

  • added support for frontend form keys, introduced in EE 1.13 and CE 1.8

4.1.1

  • fixed issue with esi tags being rendered with POST requests

4.1.0

  • added GeoIP handling

4.0.7

  • added ESI block for cookie notices

4.0.6

  • fixed minor issue with vcl

4.0.5

  • fixed issue with caching of store switching requests

4.0.4

  • fixed compatibility issue with older magento versions

4.0.3

  • fixed caching issues with non default stores

4.0.2

  • fixed issues with cms pages and widgets

4.0.1

  • fixed issues with catalog search results

4.0.0

  • added store and currency switch support
  • added advanced message handling
  • added Varnish ESI support for basic blocks (sidebar/mini cart, top links, welcome message, last viewed and compared products)
  • raised Magento version requirements to CE 1.5.1 and EE 1.9
  • dropped support for Varnish 2.x
  • moved configuration in separate tab
  • small bugfixes

3.1.1

  • Fixed some issues with register_shutdown_function() functionality (introduced in 3.1.0)

3.1.0

  • Added "Quick Purge" to clean Varnish Cache for a certain URL pattern
  • Show VCL snippet for design exception after saving
  • Added separate admin backend in VCL with longer timeout values
  • Normalize URL in case of leading HTTP scheme and domain in VCL
  • Fixed issues where redirects are cached by mistake

3.0.1

  • Fixed packaging issue with locales

3.0.0

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

1.1.0

  • Full support for Varnish 3.0
  • Replaced no-cache and X-Cache-Ttl header with standard "Expires" header
  • Removed C-code in VCLs and splitted default.vcl for 2.1 and 3.0
  • Improved hit rate and compatibility for different environments

1.0.0

  • Initial release

magento-pagecache-powered-by-varnish's People

Contributors

cranke avatar deniscsz avatar franklinkim avatar gibbs avatar huayra avatar ihor-sviziev avatar lrkwz avatar luilver avatar magekube avatar niels-phoenix avatar phoenix-bjoern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magento-pagecache-powered-by-varnish's Issues

Add to Cart Broken

Hello!

The "add to cart" function is broken after the install.

Can you help me?

I've tryed follow the README.txt but no have success.

I'm using magento 1.9.0.1 and varnish 4

ESI

Hi,

I've setup PageCache on an old 1.4.1.1 system - and everything seems to work.
I am running Varnish 4.1.8

How can I control which blocks should be loaded via ESI ?
E.g. my cart block is called "dropdown_cart" - how/where can I set that this should not be cached? Or at the very least uniquely cached per visitor?

Thanks,

404

when I enable this extension and try to visit the admin page it gives me a 404. Magento EE 1.14. Did I do something wrong?

Clean cache not purge cache

I have an issue trying to purge the cache front backend but on clean the cache, all caches it doesn't clean.

in the varnish_log i have this error:

2014-05-28T13:46:13+00:00 DEBUG (7): Purging on server localhost failed (Return status 405).
2014-05-28T13:46:13+00:00 DEBUG (7): Purged Varnish items with parameters array (
'X-Purge-Host' => '^(www.mydomain.com)$',
'X-Purge-Regex' => '.*',
'X-Purge-Content-Type' => 'text/html',
)

I think if 405 status give the purge cache will not work, is there a way to fix it?

got Fatal error in VarnishCache code

I've got Error 503 Service Unavailable from Varnish due to

[Fri Sep 12 15:46:44 2014] [error] [client 127.0.0.1] PHP Fatal error:  Call to a member function generateDesignExceptionSub() on a non-object in /var/www/test/magento/app/code/community/Phoenix/VarnishCache/Model/Observer.php on line 325, referer: https://test/index.php/admin/system_config/edit/section/design/key/155d57c56851524e46aad5d7243d2ed8/

it happens quite often on my current configuration but 1st time with varnishCache module

Enterprise Product Save Not Purging

When we save a product, the product page is never purged in varnish.

If you go to Phoenix/VarnishCache/Model/Control/Catalog/Product.php and print out the collection select in _purgeByIds(), you get something simliar to:
SELECT main_table.* FROM core_url_rewrite AS main_table WHERE (id_path IN ("product/1669")) OR (id_path LIKE "product/1669/%")

The "core_url_rewrite" table isn't used anymore in EE versions and the table should be "enterprise_url_rewrite". Is there a setting somewhere to configure it to use this table?

/varnishcachekey/getformkey/ URLENCODED

Having a weird/random issue where the getformkey is showing up urlencoded.

For instance if you went directly to this url after the issue occurs
http://www.site.com/varnishcache/getformkey/

You would get:
%3Cesi%3Ainclude%20src%3D%27http%3A//www.site.com/varnishcache/getformkey/%27%20/%3E

Something is URL encoding that url and its sporadic.

Update: For some reason, it seems specific to just Macs. I'm not sure why that would happen just on that platform though (Cookies are set properly in Chrome, but not FF or Safari)

Update2: I can replicate the formkey cookie getting corrupted on a MAC
On a Mac I can always replicate this by going directly to the CLONE server.
Check your Cookies in Firebug. Watch the "PAGECACHE_FORMKEY" as this is what is used in the /varnishcache/getformkey/
1.) Clear ALL Cookies.
2.) Goto homepage
3.) Add product to cart. From Cart "Proceed to Checkout ".
4.) On checkout page, clear all cookies again then hit refresh.
5.) You'll see that the cookie is corrupted:
PAGECACHE_FORMKEY=%3Cesi%3Ainclude%20src%3D%27http%3A//www.site.com/varnishcache/getformkey/%27%20/%3E; expires=Sun, 19 Jul 2015 16:27:51 GMT; path=/; domain=.www.site.com

I have tried doing all of the edits to Esi.php and the formkey.phtml, but none of them worked. Any insight into this would be greatly appreciated.

purge url programmatically

Is there a way to purge the url programatically?

I'm updating the stock by writing to the database directly and would like to purge product urls (or by product id) afterwards (not on product save).

Or, if not, how would you go about purging all varnish programatically? (Mage::app()->cleanCache()) doesn't work.

Thanks!

Where is model "varnishcache/vcl"?

In Phoenix_VarnishCache_Model_Observer Line 324, there is the following codes:

$designExceptionSubSnippet = Mage::getSingleton('varnishcache/vcl')

But where is model "varnishcache/vcl"?

<esi Form Key/> Not being converted to a proper form key

I've looked through all of your documentation and your issues and I can't seem to understand this problem. I'm posting my issue here as a sort of walkthrough to find the answer, if anybody has any input while I figure this out, please share.

The Problem

The <esi:include src='http://domain.com/varnishcache/getformkey/' /> string is not being properly interpreted by Varnish on my setup. I should say, that it's being interpreted properly in some locations, but not others.

2015-05-15_1251

Related Issues

I've looked at the other issues which you have in this git issue system and they are not the same. The following issues reference that the form key is breaking their website and the solution to their problems is the quotation marks being wrong.

My problem differs in that the quotation marks have been done properly and the page passes w3 parsing standards. As I mentioned, the form key has been properly parsed in the past, and in some locations it works perfectly.

Here are the other issues, which mention the same problem, but have a different solution:

  1. Issue #24
  2. Issue #21
  3. Issue #17

Possible Cause

I'm assuming that the page headers are wrong and therefore varnish doesn't know that it needs to punch a hole in the cache. I'm going to look into the page headers some more and let you know what I find.

If you have information and would like to contact me, please email me through my Magento Developer website.

No cache anymore since I switched to HTTPS

Hi,

I successfully switched to HTTPS by :

  • changing the unsecure_base_url to HTTPS
  • In .vcl: set req.http.Https = "on";
  • Added "SetEnv HTTPS on" in apache conf file

Now, Varnish is not caching anymore. Is it caused by phonix-media module which can't handle https?

I delete this "req.http.Https" in default vcl but still does not work:
# not cacheable by default
if (req.http.Authorization || req.http.Https) {
return (pass);
}

Someone has a store running on HTTPS with varnish caching static files and html pages ?

Thank you.

Cannot login directly

Hello I've quite sucessully integrated in my environment:

  • two backends
  • round-robin director

Cart is ok, checkout is ok
But ... still I cannot login from /customer/account/login/ unless I drop something in cart.

Following is my default.vcl where notably all cookies (except some relevant ones like ow_cookie_notice|PHPSESSID|NO_CACHE) are removed.

What is wrong here?

##
import std; // import logging
include "local.vcl";

sub vcl_recv {
    if (req.restarts == 0) {
        if (req.http.x-forwarded-for) {
            set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
        } else {
            set req.http.X-Forwarded-For = client.ip;
        }
    }

    if (req.request != "GET" &&
        req.request != "HEAD" &&
        req.request != "PUT" &&
        req.request != "POST" &&
        req.request != "TRACE" &&
        req.request != "OPTIONS" &&
        req.request != "DELETE" &&
        req.request != "BAN" &&
        req.request != "PURGE") {
        /* Non-RFC2616 or CONNECT which is weird. */
        return (pipe);
    }

    # purge request
    if (req.request == "PURGE") {
        if (!client.ip ~ purge) {
            error 405 "Not allowed.";
        }
        //ban("obj.http.X-Purge-Host ~ " + req.http.X-Purge-Host + " && obj.http.X-Purge-URL ~ " + req.http.X-Purge-Regex + " && obj.http.Content-Type ~ " + req.http.X-Purge-Content-Type);
        //error 200 "Purged.";
        return(lookup);
    }

    if (req.request == "BAN") {
      if(!client.ip ~ purge) {
        error 405 "Not allowed.";
      }
      if (req.http.X-Cache-Tags) {
        ban("obj.http.X-Host ~ " + req.http.X-Host
          + " && obj.http.X-Url ~ " + req.http.X-Url
          + " && obj.http.content-type ~ " + req.http.X-Content-Type
          + " && obj.http.X-Cache-Tags ~ " + req.http.X-Cache-Tags
        );
      } else {
//        ban("req.url ~ "+req.url+" && req.http.host == "+req.http.host);
        ban("obj.http.X-Purge-Host ~ " + req.http.X-Purge-Host + " && obj.http.X-Purge-URL ~ " + req.http.X-Purge-Regex + " && obj.http.Content-Type ~ " + req.http.X-Purge-Content-Type);
      }
      error 200 "Banned " + req.http.host + " " + req.url;
    }


    # no-cache request from authorized ip to warmup the cache
    if (req.http.Cache-Control ~ "no-cache" && client.ip ~ purge) {
        set req.hash_always_miss = true;
    }


    # switch to admin backend configuration
    #if (req.http.cookie ~ "adminhtml=") {
        #set req.backend = more_prod;
    #}

    # tell backend that esi is supported
    set req.http.X-ESI-Capability = "on";

    # we only deal with GET and HEAD by default
    if (req.request != "GET" && req.request != "HEAD") {
        return (pass);
    }

    # normalize url in case of leading HTTP scheme and domain
    set req.url = regsub(req.url, "^http[s]?://[^/]+", "");

    # Normalize the header, remove the port
    set req.http.host = regsub(req.http.host, ":[0-9]+", "");

    #if( req.http.host == "longtake-recommendation.moreinteractive.eu" ) {
        #set req.backend = longtake; 
    #} elseif( req.http.host == "longtake-recommendation.produzionenux.moreinteractive.eu" ) {
        #set req.backend = longtake; 
    #} elseif( req.http.host == "fidelio.moreinteractive.eu" ) {
        #set req.backend = fidelio; 
    #} elseif( req.http.host == "www.digitalacademy.it" ) {
        #set req.backend = ne733;
    #} elseif( req.http.host == "www.moreinteractive.eu" ) {
        #set req.http.host = "www.more.it";
        #error 750 "http://" + req.http.host + req.url;
    #} else {
        #set req.backend = more_prod; 
    #}


    # collect all cookies
    std.collect(req.http.Cookie);

    # static files are always cacheable. remove SSL flag and cookie
    if (req.url ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$") {
        unset req.http.Https;
        unset req.http.Cookie;
    }

    # formkey lookup
    if (req.url ~ "/varnishcache/getformkey/") {
        # check for formkey in cookie
        if (req.http.Cookie ~ "PAGECACHE_FORMKEY") {
            set req.http.X-Pagecache-Formkey = regsub(req.http.cookie, ".*PAGECACHE_FORMKEY=([^;]*)(;*.*)?", "\1");
        } else {
            # create formkey once
            set req.http.X-Pagecache-Formkey-Raw = req.http.Cookie + client.ip + req.xid;
            C{
                char *result = generate_formkey(VRT_GetHdr(sp, HDR_REQ, "\030X-Pagecache-Formkey-Raw:"));
                VRT_SetHdr(sp, HDR_REQ, "\024X-Pagecache-Formkey:", result, vrt_magic_string_end);
            }C
        }
        unset req.http.X-Pagecache-Formkey-Raw;
        error 760 req.http.X-Pagecache-Formkey;
    }

    # do not cache any page from index files
    if (req.url ~ "^/(index)") {
        return (pass);
    }

    # as soon as we have a NO_CACHE cookie pass request
    if (req.http.cookie ~ "NO_CACHE=") {
        return (pass);
    }

    # normalize Accept-Encoding header
    # http://varnish.projects.linpro.no/wiki/FAQ/Compression
    if (req.http.Accept-Encoding) {
        if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
            # No point in compressing these
            remove req.http.Accept-Encoding;
        } elsif (req.http.Accept-Encoding ~ "gzip") {
            set req.http.Accept-Encoding = "gzip";
        } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
            set req.http.Accept-Encoding = "deflate";
        } else {
            # unknown algorithm
            remove req.http.Accept-Encoding;
        }
    }

    # remove Google gclid parameters
    set req.url = regsuball(req.url, "\?gclid=[^&]+$", "");  # strips when QS = "?gclid=AAA"
    set req.url = regsuball(req.url, "\?gclid=[^&]+&", "?"); # strips when QS = "?gclid=AAA&foo=bar"
    set req.url = regsuball(req.url, "&gclid=[^&]+",   "");  # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"

    if (req.http.Cookie) {
        if (req.http.cookie !~ "PHPSESSID" && req.http.cookie ~ "REMEMBERME") {
            return(pass);
        }

        if (req.http.Cookie ~ "wordpress_logged_in_" || req.http.Cookie ~ "woocommerce_" || req.http.Cookie ~ "wp_postpass" || req.http.Cookie ~ "DokuWiki"){
            return (pass);
        } else {
            if (req.url ~ "\.(png|gif|jpg|swf|css|js)\??.*?$") {
                unset req.http.Cookie;
            } else {
                /* Warning: Not a pretty solution */
                /* Prefix header containing cookies with ';' */
                set req.http.Cookie = ";" + req.http.Cookie;
                /* Remove any spaces after ';' in header containing cookies */
                set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
                /* Prefix cookies we want to preserve with one space */
                /* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) */
                /* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post */
                /* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies */
                set req.http.Cookie = regsuball(req.http.Cookie, ";(ow_cookie_notice|PHPSESSID|NO_CACHE)=", "; \1=");
                /* Remove from the header any single Cookie not prefixed with a space until next ';' separator */
                set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", "");
                /* Remove any '; ' at the start or the end of the header */
                set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", "");
            }

            if (req.http.Cookie == "") {
                /* If there are no remaining cookies, remove the cookie header. */
                unset req.http.Cookie;
            }
        }
    }

//    return (lookup);

}

# sub vcl_pipe {
#     # Note that only the first request to the backend will have
#     # X-Forwarded-For set.  If you use X-Forwarded-For and want to
#     # have it set for all requests, make sure to have:
#     # set bereq.http.connection = "close";
#     # here.  It is not set by default as it might break some broken web
#     # applications, like IIS with NTLM authentication.
#     return (pipe);
# }

# sub vcl_pass {
#     return (pass);
# }

sub vcl_hash {
    hash_data(req.url);
    if (req.http.host) {
        hash_data(req.http.host);
    } else {
        hash_data(server.ip);
    }

    if (req.http.cookie ~ "PAGECACHE_ENV=") {
        set req.http.pageCacheEnv = regsub(
            req.http.cookie,
            "(.*)PAGECACHE_ENV=([^;]*)(.*)",
            "\2"
        );
        hash_data(req.http.pageCacheEnv);
        remove req.http.pageCacheEnv;
    }

    if (!(req.url ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$")) {
        call design_exception;
    }

    /* Hash cookie data
    As requests with same URL and host can produce diferent results when issued with different cookies,
    we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.
    */
    if (req.http.Cookie) {
      /* Include cookie in cache hash */
      hash_data(req.http.Cookie);
    }

    return (hash);
}

sub vcl_hit {
    if (req.request == "PURGE") {
        purge;
        error 204 "Purged";
    }
}

# The purge in vcl_miss is necessary to purge all variants in the cases where
# you hit an object, but miss a particular variant.
sub vcl_miss {
    if (req.request == "PURGE") {
        purge;
        error 204 "Purged (Not in cache)";
    }
}

sub vcl_fetch {
    set beresp.http.X-Backend = beresp.backend.name;
    if (beresp.status >= 500) {
       # let SOAP errors pass - better debugging
      if ((beresp.http.Content-Type ~ "text/xml") || (req.url ~ "^/errors/")) {
           return (deliver);
       }
       set beresp.saintmode = 10s;
       return (restart);
    }
    set beresp.grace = 5m;

    # enable ESI feature
    set beresp.do_esi = true;

    # add ban-lurker tags to object
    set beresp.http.X-Purge-URL  = req.url;
    set beresp.http.X-Purge-Host = req.http.host;

    if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {
        if (beresp.http.Content-Type ~ "text/html" || beresp.http.Content-Type ~ "text/xml") {
            /* By default, Varnish3 ignores Cache-Control: no-cache and private
               https://www.varnish-cache.org/docs/3.0/tutorial/increasing_your_hitrate.html#cache-control
             */
            if (beresp.http.Cache-Control ~ "private" ||
              beresp.http.Cache-Control ~ "no-cache" ||
              beresp.http.Cache-Control ~ "no-store"
            ) {
                return (hit_for_pass);
            }
            if ((beresp.http.Set-Cookie ~ "NO_CACHE=") || (beresp.ttl < 1s)) {
                set beresp.ttl = 0s;
                return (hit_for_pass);
            }
            if (req.url ~ "wp-(login|admin)|login" || req.url ~ "preview=true") {
                return (hit_for_pass);
            }

            # marker for vcl_deliver to reset Age:
            set beresp.http.magicmarker = "1";

            # Don't cache cookies
            unset beresp.http.set-cookie;
        } else {
            # set default TTL value for static content
            set beresp.ttl = 4h;
        }
        return (deliver);
    }

    return (hit_for_pass);
}

sub vcl_deliver {
    # debug info
    std.log("Client ip is: " + client.ip );
    if (client.ip ~ purge) {
        if (obj.hits > 0) {
            set resp.http.X-Cache      = "HIT";
            set resp.http.X-Cache-Hits = obj.hits;
        } else {
            set resp.http.X-Cache      = "MISS";
        }
        set resp.http.X-Cache-Expires  = resp.http.Expires;
    } else {
        # remove Varnish/proxy header
        remove resp.http.X-Backend;
        remove resp.http.X-Varnish;
        remove resp.http.Via;
        remove resp.http.Age;
        remove resp.http.X-Purge-URL;
        remove resp.http.X-Purge-Host;
        remove resp.http.X-Powered-By;
        remove resp.http.Server;
    }

    if (resp.http.magicmarker) {
        # Remove the magic marker
        unset resp.http.magicmarker;

        set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
        set resp.http.Pragma        = "no-cache";
        set resp.http.Expires       = "Mon, 31 Mar 2008 10:00:00 GMT";
        set resp.http.Age           = "0";
    }
}

sub vcl_error {
    # workaround for possible security issue
    if (req.url ~ "^\s") {
        set obj.status = 400;
        set obj.response = "Malformed request";
        synthetic "";
        return(deliver);
    }

    # formkey request
    if (obj.status == 760) {
        set obj.status = 200;
        synthetic obj.response;
        return(deliver);
    }

    # redirect request
    if (obj.status == 750) {
        set obj.http.Location = obj.response;
        set obj.status = 301;
        return(deliver);
    }

    # error 200
    if (obj.status == 200) {
        return (deliver);
    }

     set obj.http.Content-Type = "text/html; charset=utf-8";
     set obj.http.Retry-After = "5";
     synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>"} + obj.status + " " + obj.response + {"</title>
    </head>
    <body>
        <h1>Error "} + obj.status + " " + obj.response + {"</h1>
        <p>"} + obj.response + {"</p>
        <h3>Guru Meditation:</h3>
        <p>XID: "} + req.xid + {"</p>
        <hr>
        <p>Varnish cache server</p>
    </body>
</html>
"};
     return (deliver);
}


# sub vcl_fini {
#   return (ok);
# }

sub design_exception {
}

C{
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <openssl/md5.h>

    /**
     * create md5 hash of string and return it
     */
    char *generate_formkey(char *string) {
        // generate md5
        unsigned char result[MD5_DIGEST_LENGTH];
        MD5((const unsigned char *)string, strlen(string), result);

        // convert to chars
        static char md5string[MD5_DIGEST_LENGTH + 1];
        const char *hex = "0123456789ABCDEF";
        unsigned char *pin = result;
        char *pout = md5string;

        for(; pin < result + sizeof(result); pout+=2, pin++) {
            pout[0] = hex[(*pin>>4) & 0xF];
            pout[1] = hex[ *pin     & 0xF];
        }
        pout[-1] = 0;

        // return md5
        return md5string;
    }
}C

Getting "undefined symbol: MD5" when using new default_4.1.vcl

Message from dlopen:
Compiled VCL program failed to load:
  ./vcl._thEzyRX.so: undefined symbol: MD5
Running dlopen failed, exited with 1

VCL compilation failed

What can I do to fix this issue? My current Varnish version is 4.0.3 but it looks to me as if this is no issue of Varnish itself.

Retreiving formkeys via esi

I am confused about how the form key integration via esi works. The formkeys are replaced with the esi tag that has a URL: "magento/varnishcache/getformkey".
But I don't see any controller that would have this action, so how is it supposed to work? Am I missing some configuration?

default_3.0.vcl not working....ReOpened

Sorry I accidently closed the issue.

Here is the additional information you requested.

Hi Bjorn

I am hoping you can provide me with a vcl that will work in harmony with the pagecache extension.

We are using Apache webserver. Here is the response header:

Name Value Delim
Status: HTTP/1.1 200 OK
Server: Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_perl/2.0.6 Perl/v5.10.1

X-Powered-By: PHP/5.3.27

X-Mod-Pagespeed: 1.3.25.4-2941

Vary: Accept-Encoding
Content-Encoding: gzip

Content-Type: text/html; charset=utf-8

Content-Length: 12258

Accept-Ranges: bytes

Date: Thu, 07 Nov 2013 08:55:43 GMT

Connection: close

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Expires: Mon, 31 Mar 2008 10:00:00 GMT

Age: 0

Still issue with add to cart - the second time it works

Hi all

I've read all the READMEs and all the posts in the other issues (and tryed/implemented everything out).

I have the problem (since this form_key disaster) that the add to cart still doesnt work.

The first time i try to add something to the card it shows an empty cart - and the EXTERNAL_NO_CACHE cookie get set (and then afterwards it works, becouse
its bypassing Varnish becouse of the cookie).

I can not figure out what the problem is becouse the PAGECACHE_FORMKEY cookie is getting set right, and the html sourcecode shows the same key.
so its not like this esi tags didnt get replaced.

Magento site couldn't be cached when user logged in

Hi, I have installed and configured PageCache to make Varnish work with Magento.
When I am not logged in, I check the reponse header of the site and notice that Varnish works with Magento, and the site is cached by Varnish:
1

But when I log in with email and password, it seems that Varnish doesn't cache Magento site because there's a Set-Cookie header when logged in:
2

How can I resolve this problem to make Varnish work with Magento evenwhen logged in? Thank you so much!

Adding product to cart fails because of mismatched form_key

I had an older version of this without formkey support and I "solved" it by removing the formkey check when adding to cart.
Now I'm trying to update the module so that formkeys are properly handeled, but it won't work because the formkeys are not the same when the cart/add action checks it.
How is it supposed to work, because If a user comes to a cached product page and adds it to cart. Varnish will generate a formkey and replace it via ESI, but magento will do the same. What am I missing?
Edit: I'm using EE 1.14.0.1 but I've tried this on an empty Magento 1.9.2 with the same results.

Cannot restart varnish when used the default_3.0.vcl file

Hi, i have done exactly the steps for installing and configuring PageCache to make Varnish works with Magento.
I use host CentOS 6 on Amazon EC2. My webserver is NGINX. I have installed LEMP stack, Magento, Varnish and Turpentine. Below is the information of the versions i installed:

  • NGINX version: 1.0.15
  • Magento CE 1.9.1.0 with sample data
  • Varnish version: 3.0.7
  • PageCache version: 4.4.1
    The NGINX webserver is running on port 8080, and Varnish is running on port 80 to make it works together.
    I copied the file default_3.0.vcl from PageCache module and replaced the file default.vcl in my varnish config directory. But when i try to restart varnish, i got this error:

11

This is my startup varnish options from /etc/sysconfig/varnish file

DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
             -f ${VARNISH_VCL_CONF} \
             -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
             -t ${VARNISH_TTL} \
             -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \
             -u varnish -g varnish \
             -S ${VARNISH_SECRET_FILE} \
             -s ${VARNISH_STORAGE} \
             -p esi_syntax=0x03 \
             -p shm_reclen=4096 \
             -p 'cc_command=exec cc -fpic -shared -Wl,-x -o %o %s -lcrypto -lssl'"

Please help me to fix this problem as soon as possible, thank you so much!

Slow Magento backend

Hi

we did install Varnish and Turpentine on our server. We use the latest 1.8 Magento.
The frontend is working gr8 after 1 day of running but we do have big problems in our Magento backend.

  • Slow admin pages
  • Slow product saving (up to 1 min) before it was 5 sec.

Any Idea what can be wrong?
Thanks

Product Page - Links Broken? Please Help!

Hello! I installed the latest version of Varnish Server 3 and the module Page Cache following exactly the instructions in the Readme.txt file.

But in my product page some strange things are happening:

It appears this aima product code name:

/ "Method =" post "id =" product_addtocart_form ">" />

And this code below the button add to cart:

/ "Onclick =" productAddToCartForm.submitLight (this, this.href); return false; "class =" link-wishlist ">

To try to help you understand my problem, follows some pictures of headers:

chache1
headers1
headers2
cokies

[Feature Request] Only Purge Category/Product page when product QTY reaches 0

Hi there,

We've got a few websites using this module, which works brilliantly.

The only issue we have with it is during sale time, where we can get some performance problems with cache thrashing.

During a sale we would normally have lots of products moved to a top level category called Sale (so for example Sale/Men, Sale/Women, Sale/Men/Shirts... etc etc.)

This issue this presents is that during high load, any sale of a product causes the cache to be cleaned all the way up to the top category "Sale" - which means this page is constantly being knocked out of the cache and re-generated.

Would it be possible to build in a way to only clear the cache for product page/categories if the "isSaleable" or similar changes?

Thanks
Mike

Missing Singleton VCL

There's a missing singleton class call Mage::getSingleton('varnishcacheenterprise/vcl') in the app/code/community/Phoenix/VarnishCache/Model/Observer.php file.

    /**
     * Shows notice to update Varnish VCL file
     *
     * @param Varien_Event_Observer $observer
     * @return Phoenix_VarnishCache_Model_Observer
     */
    public function showVclUpdateMessage(Varien_Event_Observer $observer)
    {
        try {
            Mage::getSingleton('core/session')->addNotice(
                Mage::helper('varnishcache')->__(
                    'Update Varnish VCL with design exceptions by using the following snippet:'
                )
            );

            // THIS DOES NOT EXIST
            $designExceptionSubSnippet = Mage::getSingleton('varnishcacheenterprise/vcl')
                ->generateDesignExceptionSub();

            $designExceptionSubSnippet = str_replace(' ', '&nbsp;', $designExceptionSubSnippet);
            $designExceptionSubSnippet = nl2br($designExceptionSubSnippet);

            Mage::getSingleton('core/session')->addNotice($designExceptionSubSnippet);
        } catch (Exception $e) {
            $msg = 'Failed to prepare vcl: '.$e->getMessage();
            Mage::helper('varnishcache')->debug($msg);
            Mage::throwException($msg);
        }

        return $this;
    }

Not caching after add a product to cart

I have noticed via support ticket the issue but i see that was ignored, the issue with this module is that when you add a product to the basket, Varnish just break and MISS every hit, tested on http://magento.phoenix-media.eu/

  1. Navigate all pages, to get the first hit.
  2. Add a product to cart, Checkout or just Delete it from cart.
  3. Navigate again the pages you've navigated before, and see if are still fast.

On firebug you will see that X-Cache will return MISS, to cache again you need to remove the cookies from the entire site, and voila it will cache again.

But... you need to tell this to each client visit your webiste...
So, for some people that just navigate your website and not add a product to cart is good, but for possible buyers the varnish module is not good, also on add a product to cart it show empty cart !.

Hope the team resolve this issue !

Downloader converted files to directories

So i installed via magento downloader
These files were converted to directories of the same name.
I had to delete the directories and downloaded the latest code from github.

/app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Category/Product/Collection.php
/app/code/community/Phoenix/VarnishCache/Model/Resource/Mysql4/Catalog/Product/Relation/Collection.php

Cannot redeclare Phoenix_VarnishCache_Adminhtml_VarnishCacheController::_isAllowed() in VarnishCacheController.php on line 155

This error is occurs when we click on Clean Varnish Cache. (varnishCache/clean):

"PHP message: PHP Fatal error: Cannot redeclare Phoenix_VarnishCache_Adminhtml_VarnishCacheController::_isAllowed() in /htdocs/.modman/Magento-PageCache-powered-by-Varnish/app/code/community/Phoenix/VarnishCache/controllers/Adminhtml/VarnishCacheController.php on line 155" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php/admin/varnishCache/clean/key/7fe0841ea92203345929f2bbd2f512d4/

PageCache powered by Varnish Community version: 4.4.1
Magento version: 1.8.1.0
PHP version: 5.5.9

Compiling of default_4.1.vcl fails with Cannot create .eh_frame_hdr section [...]

What am I missing here? Thank you.

_@lima /etc/systemd/system # service varnish start
Job for varnish.service failed. See 'systemctl status varnish.service' and 'journalctl -xn' for details.
_@lima /etc/systemd/system # systemctl status -l varnish.service
● varnish.service - Varnish Cache, a high-performance HTTP accelerator
Loaded: loaded (/etc/systemd/system/varnish.service; disabled)
Active: failed (Result: exit-code) since Fri 2016-01-15 16:26:31 CET; 14s ago
Process: 17994 ExecStart=/usr/sbin/varnishd -a :80 -T localhost:6082 -f /etc/varnish/magento.vcl -S /etc/varnish/secret -p feature=+esi_disable_xml_check,+esi_ignore_other_elements -p vsl_reclen=4084 -p vcc_allow_inline_c=on -p cc_command=exec cc -fpic -shared -Wl,-x -o %o %s -lcrypto -lssl -s malloc,1G (code=exited, status=2)

Jan 15 16:26:31 lima varnishd[17994]: /usr/bin/ld: warning: Cannot create .eh_frame_hdr section, --eh-frame-hdr ignored.
Jan 15 16:26:31 lima varnishd[17994]: /usr/bin/ld: error in /bin/sh(.eh_frame); no .eh_frame_hdr table will be created.
Jan 15 16:26:31 lima varnishd[17994]: Message from dlopen:
Jan 15 16:26:31 lima varnishd[17994]: Could not load compiled VCL.
Jan 15 16:26:31 lima varnishd[17994]: dlopen(vcl_boot/vgc.so) = vcl_boot/vgc.so: symbol lxstat, version GLIBC_2.2.5 not defined in file libc.so.6 with link time reference
Jan 15 16:26:31 lima varnishd[17994]: Running dlopen failed, exited with 1
Jan 15 16:26:31 lima varnishd[17994]: VCL compilation failed
Jan 15 16:26:31 lima systemd[1]: varnish.service: control process exited, code=exited status=2
Jan 15 16:26:31 lima systemd[1]: Failed to start Varnish Cache, a high-performance HTTP accelerator.
Jan 15 16:26:31 lima systemd[1]: Unit varnish.service entered failed state.

<config>
    <modules>
        <Phoenix_VarnishCache>
            <version>4.4.0</version>
        </Phoenix_VarnishCache>
    </modules>

_@lima /etc/systemd/system # varnishd -V
varnishd (varnish-4.1.0 revision 3041728)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2015 Varnish Software AS
_@lima /etc/systemd/system # uname -a
Linux lima 3.16.0-4-amd64 # 1 SMP Debian 3.16.7-ckt20-1+deb8u2 (2016-01-02) x86_64 GNU/Linux
_@lima /etc/systemd/system # dpkg -s libc6 | grep ^Version
Version: 2.19-18+deb8u1
_@lima /etc/systemd/system # dpkg -s openssl | grep ^Version
Version: 1.0.1k-3+deb8u2
_@lima /etc/systemd/system # dpkg -s libssl-dev | grep ^Version
Version: 1.0.1k-3+deb8u2

Admin Port and Admin Secret not in configuration page

Hello,

although README.md informs to configure Admin Port and Admin Secret, those fields are not present in the phoenix-media pagecache configuration page.
They are neither present in core_config_data table or grepping the downloaded code.
Is there another way to inform the plugin about admin port and admin secret?
If you press the purge varnish cache button at the cache configuration page it says it's ok, but how has it spoken to varnish without knowing both admin port and admin secret?

Thanks

Varnish Not Cache When Cookie EXTERNAL_NO_CACHE added

Hai, I have issue with magento varrnish caching, and found this extension for manage it. but after I install and try the caching performance, I found issue while some cookie show on magento.

  1. while I see caching performance on magento home its find, there is cookie called "frontend" show and its handled, page document load 8ms its very fast.
  2. I go to product category page and its also work.
  3. I go to product vview page and its also work with new cookies "external_no_cache, PAGECHACHE_FORMKEY".
  4. but after I add product to cart, the page performance go down became 800ms, and after that, in all page mageto, load page became above 700ms cache varnish pass, not work.
  5. I try see whats the problem and found the new cookie called "EXTERNAL_NO_CACHE", affter I remove this cookie page load run normal again with page load 8ms varnish cache work.
  6. I try to create cookie with "NO_CACHE" word, and page not caching, page load became increase above 500ms.

so whats the problem?, its because thats cookie all varnish cache not work?. or because session product cart.? please help me to solve this. thanks.

Can't set up varnish, missing something here... Getting Miss

My configs:
/etc/sysconfig/varnish

# Configuration file for varnish
#
# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
# shell script fragment.
#

# Maximum number of open files (for ulimit -n)
NFILES=131072

# Locked shared memory (for ulimit -l)
# Default log size is 82MB + header
MEMLOCK=82000

# Maximum number of threads (for ulimit -u)
NPROCS="unlimited"

# Maximum size of corefile (for ulimit -c). Default in Fedora is 0
#DAEMON_COREFILE_LIMIT="unlimited"

# Set this to 1 to make init script reload try to switch vcl without restart.
# To make this work, you need to set the following variables
# explicit: VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_ADDRESS,
# VARNISH_ADMIN_LISTEN_PORT, VARNISH_SECRET_FILE, or in short,
# use Alternative 3, Advanced configuration, below
RELOAD_VCL=1

# This file contains 4 alternatives, please use only one.

## Alternative 1, Minimal configuration, no VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# content server on localhost:8080.  Use a fixed-size cache file.
#
#DAEMON_OPTS="-a :6081 \
#             -T localhost:6082 \
#             -b localhost:8080 \
#             -u varnish -g varnish \
#             -s file,/var/lib/varnish/varnish_storage.bin,1G"


## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request.  Use a
# fixed-size cache file.
#
#DAEMON_OPTS="-a :80 \
#             -T localhost:6082 \
#             -f /etc/varnish/default.vcl \
#             -u varnish -g varnish \
#             -S /etc/varnish/secret \
#             -s file,/var/lib/varnish/varnish_storage.bin,1G"

## Alternative 3, Advanced configuration
#
# See varnishd(1) for more information.
#
# # Main configuration file. You probably want to change it :)
VARNISH_VCL_CONF=/home/admin/public_html/golulo.es/etc/varnish/prototype.vcl
#
# # Default address and port to bind to
# # Blank address means all IPv4 and IPv6 interfaces, otherwise specify
# # a host name, an IPv4 dotted quad, or an IPv6 address in brackets.
# VARNISH_LISTEN_ADDRESS=
VARNISH_LISTEN_PORT=80
#
# # Telnet admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
#
# # Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret
#
# # The minimum number of worker threads to start
VARNISH_MIN_THREADS=50
#
# # The Maximum number of worker threads to start
VARNISH_MAX_THREADS=1000
#
# # Idle timeout for worker threads
VARNISH_THREAD_TIMEOUT=120
#
# # Cache file location
VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
#
# # Cache file size: in bytes, optionally using k / M / G / T suffix,
# # or in percentage of available disk space using the % suffix.
VARNISH_STORAGE_SIZE=2G
#
# # Backend storage specification
VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"
#
# # Default TTL used when the backend does not specify one
VARNISH_TTL=120
#
# # DAEMON_OPTS is used by the init script.  If you add or remove options, make
# # sure you update this section, too.
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
             -f ${VARNISH_VCL_CONF} \
             -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
             -t ${VARNISH_TTL} \
             -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \
             -u varnish -g varnish \
             -S ${VARNISH_SECRET_FILE} \
             -s ${VARNISH_STORAGE} \
             -p esi_syntax=0x03 \
             -p shm_reclen=4096"

#

## Alternative 4, Do It Yourself. See varnishd(1) for more information.
#
# DAEMON_OPTS=""

.vcl (I don't specify the name of the .vcl for a reason, will explain down in the post)

# This is a basic VCL configuration file for PageCache powered by Varnish for Magento module.

# include variable handling methods
include "/home/admin/public_html/golulo.es/etc/varnish/vars.vcl";

# default backend definition.  Set this to point to your content server.
backend default {
  .host = "81.21.65.97";
  .port = "82";
}

# admin backend with longer timeout values. Set this to the same IP & port as your default server.
backend admin {
  .host = "81.21.65.97";
  .port = "82";
  .first_byte_timeout = 18000s;
  .between_bytes_timeout = 18000s;
}

# add your Magento server IP to allow purges from the backend
acl purge {
  "localhost";
  "81.21.65.97";
}

import std;

sub vcl_init {
    C{
        /* set random salt */
        srand(time(NULL));

        /* init var storage */
        init_function(NULL, NULL);
    }C
}

sub vcl_recv {
    if (req.restarts == 0) {
        if (req.http.x-forwarded-for) {
            set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
        } else {
            set req.http.X-Forwarded-For = client.ip;
        }
    }

    if (req.request != "GET" &&
        req.request != "HEAD" &&
        req.request != "PUT" &&
        req.request != "POST" &&
        req.request != "TRACE" &&
        req.request != "OPTIONS" &&
        req.request != "DELETE" &&
        req.request != "PURGE") {
        /* Non-RFC2616 or CONNECT which is weird. */
        return (pipe);
    }

    # purge request
    if (req.request == "PURGE") {
        if (!client.ip ~ purge) {
            error 405 "Not allowed.";
        }
        ban("obj.http.X-Purge-Host ~ " + req.http.X-Purge-Host + " && obj.http.X-Purge-URL ~ " + req.http.X-Purge-Regex + " && obj.http.Content-Type ~ " + req.http.X-Purge-Content-Type);
        error 200 "Purged.";
    }

    # switch to admin backend configuration
    if (req.http.cookie ~ "adminhtml=") {
        set req.backend = admin;
    }

    # we only deal with GET and HEAD by default
    if (req.request != "GET" && req.request != "HEAD") {
        return (pass);
    }

    # normalize url in case of leading HTTP scheme and domain
    set req.url = regsub(req.url, "^http[s]?://[^/]+", "");

    # collect all cookies
    std.collect(req.http.Cookie);

    # static files are always cacheable. remove SSL flag and cookie
    if (req.url ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$") {
        unset req.http.Https;
        unset req.http.Cookie;
    }

    # check if we have a formkey cookie
    if (req.http.Cookie ~ "PAGECACHE_FORMKEY") {
        set req.http.x-var-input = regsub(req.http.cookie, ".*PAGECACHE_FORMKEY=([^;]*)(;*.*)?", "\1");
        call var_set;
    } else {
        # create formkey once
        if (req.esi_level == 0) {
            C{
                generate_formkey(sp, 16);
            }C
            set req.http.x-var-input = req.http.X-Pagecache-Formkey;
            call var_set;
        }
    }
    # cleanup variables
    unset req.http.x-var-input;
    unset req.http.X-Pagecache-Formkey;

    # formkey lookup
    if (req.url ~ "/varnishcache/getformkey/") {
        call var_get;
        error 760 req.http.x-var-output;
    }

    # not cacheable by default
    if (req.http.Authorization || req.http.Https) {
        return (pass);
    }

    # do not cache any page from index files
    if (req.url ~ "^/(index)") {
        return (pass);
    }

    # as soon as we have a NO_CACHE cookie pass request
    if (req.http.cookie ~ "NO_CACHE=") {
        return (pass);
    }

    # remove Google gclid parameters
    set req.url = regsuball(req.url, "\?gclid=[^&]+$", "");  # strips when QS = "?gclid=AAA"
    set req.url = regsuball(req.url, "\?gclid=[^&]+&", "?"); # strips when QS = "?gclid=AAA&foo=bar"
    set req.url = regsuball(req.url, "&gclid=[^&]+",   "");  # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"

    return (lookup);
}

# sub vcl_pipe {
#     # Note that only the first request to the backend will have
#     # X-Forwarded-For set.  If you use X-Forwarded-For and want to
#     # have it set for all requests, make sure to have:
#     # set bereq.http.connection = "close";
#     # here.  It is not set by default as it might break some broken web
#     # applications, like IIS with NTLM authentication.
#     return (pipe);
# }

# sub vcl_pass {
#     return (pass);
# }

sub vcl_hash {
    hash_data(req.url);
    if (req.http.host) {
        hash_data(req.http.host);
    } else {
        hash_data(server.ip);
    }

    if (req.http.cookie ~ "PAGECACHE_ENV=") {
        set req.http.pageCacheEnv = regsub(
            req.http.cookie,
            "(.*)PAGECACHE_ENV=([^;]*)(.*)",
            "\2"
        );
        hash_data(req.http.pageCacheEnv);
        remove req.http.pageCacheEnv;
    }

    if (!(req.url ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$")) {
        call design_exception;
    }
    return (hash);
}

# sub vcl_hit {
#     return (deliver);
# }

# sub vcl_miss {
#     return (fetch);
# }

sub vcl_fetch {
    if (beresp.status >= 500) {
       if (beresp.http.Content-Type ~ "text/xml") {
           return (deliver);
       }
       set beresp.saintmode = 10s;
       return (restart);
    }
    set beresp.grace = 5m;

    # enable ESI feature if needed
    if (beresp.http.X-Cache-DoEsi == "1") {
        set beresp.do_esi = true;
    }

    # add ban-lurker tags to object
    set beresp.http.X-Purge-URL  = req.url;
    set beresp.http.X-Purge-Host = req.http.host;

    if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {
        if (beresp.http.Content-Type ~ "text/html" || beresp.http.Content-Type ~ "text/xml") {
            if ((beresp.http.Set-Cookie ~ "NO_CACHE=") || (beresp.ttl < 1s)) {
                set beresp.ttl = 0s;
                return (hit_for_pass);
            }

            # marker for vcl_deliver to reset Age:
            set beresp.http.magicmarker = "1";

            # Don't cache cookies
            unset beresp.http.set-cookie;
        } else {
            # set default TTL value for static content
            set beresp.ttl = 4h;
        }
        return (deliver);
    }

    return (hit_for_pass);
}

sub vcl_deliver {
    # debug info
    if (resp.http.X-Cache-Debug) {
        if (obj.hits > 0) {
            set resp.http.X-Cache      = "HIT";
            set resp.http.X-Cache-Hits = obj.hits;
        } else {
            set resp.http.X-Cache      = "MISS";
        }
        set resp.http.X-Cache-Expires  = resp.http.Expires;
    } else {
        # remove Varnish/proxy header
        remove resp.http.X-Varnish;
        remove resp.http.Via;
        remove resp.http.Age;
        remove resp.http.X-Purge-URL;
        remove resp.http.X-Purge-Host;
    }

    if (resp.http.magicmarker) {
        # Remove the magic marker
        unset resp.http.magicmarker;

        set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
        set resp.http.Pragma        = "no-cache";
        set resp.http.Expires       = "Mon, 31 Mar 2008 10:00:00 GMT";
        set resp.http.Age           = "0";
    }
}

sub vcl_error {
    # workaround for possible security issue
    if (req.url ~ "^\s") {
        set obj.status = 400;
        set obj.response = "Malformed request";
        synthetic "";
        return(deliver);
    }

    # formkey request
    if (obj.status == 760) {
        set obj.status = 200;
        synthetic obj.response;
        return(deliver);
    }

    # error 200
    if (obj.status == 200) {
        return (deliver);
    }

     set obj.http.Content-Type = "text/html; charset=utf-8";
     set obj.http.Retry-After = "5";
     synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>"} + obj.status + " " + obj.response + {"</title>
    </head>
    <body>
        <h1>Error "} + obj.status + " " + obj.response + {"</h1>
        <p>"} + obj.response + {"</p>
        <h3>Guru Meditation:</h3>
        <p>XID: "} + req.xid + {"</p>
        <hr>
        <p>Varnish cache server</p>
    </body>
</html>
"};
     return (deliver);
}


# sub vcl_fini {
#   return (ok);
# }

sub design_exception {
}

C{
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>

    /**
     * create a random alphanumeric string and store it in
     * the request header as X-Pagecache-Formkey
     */
    char *generate_formkey(struct sess *sp, int maxLength) {
        char *validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        int validCharsLength = strlen(validChars);
        char *result = (char *) malloc(maxLength + 1);

        // generate string
        int i;
        for (i = 0; i < maxLength; ++i) {
            int charPosition = rand() % validCharsLength;
            result[i] = validChars[charPosition];
        }
        result[maxLength] = '\0';

        // set req.X-Country-Code header
        VRT_SetHdr(sp, HDR_REQ, "\024X-Pagecache-Formkey:", result, vrt_magic_string_end);

        return 0;
    }
}C

Now the confusion I'm having:
As you can see my varnish config states:

# # Main configuration file. You probably want to change it :)
VARNISH_VCL_CONF=/home/admin/public_html/golulo.es/etc/varnish/prototype.vcl

http://www.isvarnishworking.com/ - indicated, that cache is enabled and running, with issues though.

I've modified the file with the content's of the default.vcl, changing to my ip adress and get misses all the time.

The default.vcl is also in the same directory as the prototype.vcl, so witch one is that varnish uses? Witch one I have to modify for it to work?
Do I need to add my ip or use the localhost or 127.0.0.1? Everything (Varsnish, website etc. is on the same server).

I did try mayority of this thing's I'm asking, but maybe I made a mistake somewhere and I can't see it.

Could you please help me?

If I'm not making my self clear, please ask I will provide all the information needed.

I'm stuck with it for day's and I can't make it to work...

2nd issue:

Getting damaged code with form_keys on product pages and in the cart, as you can see from the config the varnish startup config is modified as specified in the documentation, any ideas what may cause this?

Thank you.

Varnish 4.0 support

Hi,
Varnish 4.0 was released recently and I'm interested in testing this module against it. From what I can tell it seems the VCL should be easy enough to adapt to the new syntax.

Can you foresee any compatibility issues with this plugin and Varnish 4? Perhaps it might be worth including a default-4.0.vcl config file too.

Problem with add to whishlist

Hello,

i have a problem with PageCache with "Add to whishlist" link. Linkls are like that :

http://site.domain.com/wishlist/index/add/product/1081/form_key/%3Cesi:include%20src=%22http://site.domain.com/varnishcache/getformkey/index/_nosid/1/?SID=tg0u8h8e058ksal9u52tnc3eh1%22%20/%3E/

And when I clic on link I have the whishlist page I have a page with that :

%3Cesi%3Ainclude%20src%3D%22http%3A//site.domain.com/varnishcache/getformkey/index/_nosid/1/%3FSID%3Dtg0u8h8e058ksal9u52tnc3eh1%22%20/%3E

Technical informations:
Magento CE : 1.8.00
Varnish 3.0.6

Varnish Daemon options :
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT}
-f ${VARNISH_VCL_CONF}
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT}
-t ${VARNISH_TTL}
-w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT}
-s ${VARNISH_STORAGE}
-p esi_syntax=0x03 -p shm_reclen=4096"

Thanks for your help

Sincerely
Guidtz

Problem when I add a product in cart first time

I noticed when I visit my ecommerce first time the cookie key "frontend" is not created, only after visit area that doesn't have a cache. The problem is when I use ajax to add a cart and there is no a cookie key "frontend", the cart remains empty.
How I resolve it?

Age = 0

My test server is this one http://176.111.193.53:8080/news.html
After setup PageCache module and Varnish server following exactly what described in the document, I debug request header and see that:

Age 0
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection keep-alive
Content-Encoding gzip
Content-Type text/html; charset=UTF-8
Date Wed, 22 Oct 2014 13:30:21 GMT
Expires Mon, 31 Mar 2008 10:00:00 GMT
Pragma no-cache
Server Apache/2.2.15 (CentOS)
Transfer-Encoding chunked
Vary Accept-Encoding,User-Agent
X-Cache-Debug 1
X-Cache-Doesi 1
X-Cache-Expires Mon, 31 Mar 2008 10:00:00 GMT
X-Frame-Options SAMEORIGIN
X-Powered-By PHP/5.4.32
X-Purge-Host 176.111.193.53:8080
X-Purge-URL /news.html
X-Varnish 1421929504
via 1.1 varnish
x-cache MISS

Rarely i have a HIT but yes i do have it sometimes. If i use Varnishstat i can see ratio is only ~0,2 - 0.4
i use Varnish version 3 , server centos, apache, php_mod, file default.vcl 3 in pagecache module

Using this website http://www.isvarnishworking.com/ it tells me age = 0 means Varnish is not actually serving the content for that url from cache. Is that right? What should i do?

In .htaccess file i have this Header set Cache-Control "max-age=691200, public, must-revalidate"
but on frontpage i still see Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0, how can i turn this off and should i do it?

i also see this cookie external_no_cache = 1

i installed this module Inovarti_FixAddToCartMage18.xml https://github.com/deivisonarthur/Inovarti_FixAddToCartMage18/blob/master/README.md

Problems with Add to cart

As other users happen to them, sometimes we can't add products to the shopping cart. It goes to an "empty cart".

We have instrumented the addAction method in CartController like this:

public function addAction() {
Mage::log('AddAction: 1a Start: '.$this->getRequest()->getParam('form_key', 'null').";");
Mage::log('AddAction: 1b Start: '.Mage::getSingleton('core/session')->getFormKey().";");

And we observe that when we have this module enabled the logs we obtain is:

2016-11-21T13:40:03+00:00 DEBUG (7): AddAction: 1a Start: gELlVR6h6R9z1bQ1;
2016-11-21T13:40:03+00:00 DEBUG (7): AddAction: 1b Start: qKENHGY5iJRrkuYB;

2016-11-21T13:40:16+00:00 DEBUG (7): AddAction: 1a Start: Xs3xRkkwnVxd8P3n;
2016-11-21T13:40:16+00:00 DEBUG (7): AddAction: 1b Start: qKENHGY5iJRrkuYB;

2016-11-21T13:40:47+00:00 DEBUG (7): AddAction: 1a Start: gELlVR6h6R9z1bQ1;
2016-11-21T13:40:47+00:00 DEBUG (7): AddAction: 1b Start: qKENHGY5iJRrkuYB;

We observe that the formkey provided by the magento session is the same in every interaction.
If we disable your module, we get the following pairs of logs:

2016-11-21T13:45:49+00:00 DEBUG (7): AddAction: 1a Start: Ajm7MVeSUyZgDQE3;
2016-11-21T13:45:49+00:00 DEBUG (7): AddAction: 1b Start: Ajm7MVeSUyZgDQE3;

2016-11-21T13:46:15+00:00 DEBUG (7): AddAction: 1a Start: 3M0PmMXVa8GG8dTw;
2016-11-21T13:46:15+00:00 DEBUG (7): AddAction: 1b Start: 3M0PmMXVa8GG8dTw;

2016-11-21T14:13:59+00:00 DEBUG (7): AddAction: 1a Start: 2VARZ8HVq3M4mjiV;
2016-11-21T14:13:59+00:00 DEBUG (7): AddAction: 1b Start: 2VARZ8HVq3M4mjiV;

All of them were correct additions to the cart.

We observed too that the PAGECACHE_FORMKEY cookie is present in every interaction, including the ones with the disabled module.

The PAGECACHE_FORMKEY is emited ever, including the extension disabled?

Thanks in advanced for you help.
It hope that helps.

Fatal error: Call to a member function generateDesignExceptionSub()

Hey folks, I've been updated the module to the version 4.2.3, but when I save the configuration in the admin:

Fatal error: Call to a member function generateDesignExceptionSub() on a non-object in /att/arclube/app/code/community/Phoenix/VarnishCache/Model/Observer.php on line 325

Any Idea?

the code is:

            $designExceptionSubSnippet = Mage::getSingleton('varnishcache/vcl')
                ->generateDesignExceptionSub();

But I not found the Model! o.0

Switching Module Off Leaves ESI tags

After switching the module in magento configuration, the frontend still contains esi:includes for my formkeys.
I've cleared the cache, and reindexed.

please improve guide/howto

you wrote:

Copy the VCL file bundled with the PageCache module for your version of Varnish (located at app/code/local/Phoenix/VarnishCache/etc/default*.vcl)

but correct path is:

app/code/community/Phoenix/VarnishCache/etc/default_3.0.vcl

you did'nt write if and where copy composer.json

and finally if I go to system > configuration > pagecache powered I've "404 Error Page not found."

Version tags

Hi,

Could you please create version tags?
It would make usage of the module via composer easier.

Thanks in advance,
Andrey

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.