Varnish on Magento 1
Although Varnish is extremely awesome when it get’s to speeding up websites, Varnish is a complex technique that needs some experience to set it up. Don’t implement Varnish on production nodes while still under development but use a development node or a Hypernode Vagrant instead.
Table of contents
Configure Varnish for Magento 1.x
Before installing Turpentine we recommend changing the Varnish Cache settings in your Service Panel to active (change to ‘Actief’). Once you’ve changed this setting and enabled Varnish in Magento, Varnish will store all information in it’s own cache. Only when Varnish needs data that hasn’t been cached it will connect with the server.
Installing Turpentine works best with Magento Connect Manager:
- Log on to your backend
- Navigate to System > Magento Connect > Magento Connect Manager
- Fill in your admin credentials
- Paste the following key in the field next to Paste extension key to install:
- Click Proceed
- Turpentine will now be installed
- Log off and on again so Turpentine will appear in your admin
- Flush your Magento cache via the backend (System → Cache Management)
When the Magento Connect Manager is not available, Turpentine needs to be installed by manually:
There are a couple of options for this:
* Download and install the tarball package from the Downloads page on GitHub (note that this is not the “Download as tar.gz” option) and install through Magento Connect Downloader or Magento’s
* Install with Modman. You would just need to use:
modman clone https://github.com/nexcess/magento-turpentine.git
Note: If you install with
modman you should also set
System > Configuration > Developer > Template Settings > Allow Symlinks to “Yes”.
After installing Turpentine and flushing the Magento cache, you can start configuring Turpentine:
- Log on to your Byte Service Panel
- Select your Hypernode plan
- Click on the tab Instellingen
- Select the option
- You’ll notice Varnish cache is non-active. This is necessary for testing your shop with Varnish. (See ‘Test your shop with Varnish’ below)
- Don’t close this page, you’ll need this information later
- Log on to your Magento backend
- Navigate to System -> Configuration
- Select Varnish Options under
- In the
Serverssection, fill in the following information:
- Varnish version: leave this on ‘auto’
- Varnish server list: Paste the content from your Service Panel here
- Varnish authentication key: Paste the content from your Service Panel here
- Check if the following information is correct:
- Backend host: This should say
- Backend port: This should say
- Crawler ip’s: Remove
127.0.0.1from the crawler ip’s
- Backend host: This should say
- Navigate to System -> Cache Management
- Enable >Varnish Pages and >Varnish ESI Blocks
- Click Apply Varnish Config below to complete the configuration
Test your shop with Varnish
We highly recommend you to test Varnish on a staging environment first. This way you’ll make sure your shop is completely optimized and ready to use Varnish.
There are 2 ways to create a Hypernode staging environment for testing Varnish;
We recommend you to use a development node (which can be cancelled any time). A basic staging environment doesn’t work well with Varnish.
If you want debugging headers, please remember to enable those in the admin backend under Varnish settings.
Depending on the version of turpentine you use, sometimes it’s needed to add your ip to the
debug_acl in the
vcl. This enabled debug headers for your IP address.
Varnish with PHP7
The current stable release of the Turpentine varnish extension is compatible with PHP7.
Warm your cache with the Turpentine cache-warmer script
Turpentine is shipped with a cache warmer. To use this script copy it to your home directory:
mkdir -p ~/bin; cp ~/public/.modman/magento-turpentine/util/warm-cache.sh ~/bin/
Now you can warm your Varnish cache by retrieving the
~/bin/warm-cache.sh -u http://example.com/magento/sitemap.xml
Which will crawl all URLs defined in the
app@gz20le-support-magweb-do:~$ bash ~/bin/warm-cache.sh -u https://example.com/sitemap.xml Getting URLs from sitemap... Warming 152 URLs using 2 processes... HTTP/1.1 200 0.87 secs: 18320 bytes ==> /kamelen.html HTTP/1.1 200 1.34 secs: 14710 bytes ==> /dromedarissen.html HTTP/1.1 200 0.75 secs: 17726 bytes ==> /geiten.html HTTP/1.1 200 0.74 secs: 17974 bytes ==> /tux.html HTTP/1.1 200 0.79 secs: 14856 bytes ==> /vogelbekdier.html
- If your Varnish setup is not working over SSL, check this article.