FYI this is running on Magento 1.5.1 running LSWS over apache. But it will work just fine with straight apache. Instructions are the same. Other versions of Magento I don’t know about.
Backup your Data before installing this and make sure your magento install is running smoothly before installing this. Having a double caching system behind a reverse poxy makes it very confusing to troubleshoot other issues with dynamic content.
Get varnish > 3.0 installed and running, listening on port 8080 for the time being.
Grab my zip, extract and upload the app and js folders. Refresh magento cache, logout and login. Visit system > configuration > system and you will see configs for PageCache powered by varnish and AOE static. Configure them as follows:
AOE Static is simple:
You can add more routes to this for content created by other extensions.
PageCache should be set as follows:
Enable cache module: Yes
Varnish servers: Your IP Address
Server port: 80
Disable caching: No
Disable caching for routes: (checkout customer moneybookers paypal wishlist catalogsearch) all on seperate lines.
Disable caching vars: currency,order
Default cache TTL: 2592000 (30 days)
Cache TTL for routes: (Remove all routes here, this is controlled by AOE Static)
Purge category: Yes
Purge product: Yes
Purge CMS page: Yes
Save and refresh cache.
The third folder in my zip contains my .vcl to use with varnish and my altered varnish startup file. You can change the startup file to use varnish data handling however you wish. I personally like using “persistant” because it creates and locks silos as it’s caching so when I reboot my server all my locked silos remain in place and I don’t have to recrawl my site.
You will need to change the IP addresses in the .vcl and the varnish startup file obviously. I’ve replaced my IP with “yourdedicatedipaddress”.
Put these files in place and
from the shell.
service varnish stop
Change your website’s listening port to 8080. If your using apache config files you can change this in the httpd.conf file.
The location of this file may be different than mine. Mine is located at /usr/local/apache/conf/httpd.conf (Make a Backup!) You will need to change the Virtual Host settings for your website so it listens on port 8080. If you are using a cpanel install be aware that easyapache will overwrite your changes to this file if you change the apache configuration in WHM so you will want to make a backup of your modified file as well.
Restart your web server and verify that this is working properly before you try messing with varnish. You can verify this by visiting your website’s front page. It should be dead. Now vistit your website at port 8080, it should load as normal. Don’t bother trying to traverse through your website, only the first page will load correctly, after that magento will try to point you to your website without the port 8080.
service varnish start
If you understand how <route>_<controller>_<action> works in magento you can add additional hole punching in app/design/frontend/base/default/layout/aoestaticdemo/aoestaticdemo.xml. but as I stated in my previous post the only thing missing is a hole punch for product availability.
If you have the following line in your .htaccess file it will need to be commented out, varnish can not handle User Agent entries in page headers.
#Header append Vary User-Agent env=!dont-vary
When everything is done you should end up with a fully integrated full page cache that will purge cache for individual products and categories when the item is saved from the back end or purchased from the front end. Saving a category purges the varnish cache for that category, same with CMS pages. With AOE Static in place you will still serve up varnish cache pages even when the customer has logged in or added products to thier cart. Only the routes set in “Disable caching for routes” will not be cached. And of course when the user is accessing VIA SSL.
Check your var/log/varnish_cache.log file for varnish cache purging logs and debugging info.
Things it wont do:
It will not automatically create cached pages, you have to visit them to cache them.
It will not purge cache when using bulk attribute updates.
Depending on the extensions you are using you may want to check the canonical url meta tag of pages generated by extensions that write there own canonical tags. For some reason they seem to output the alternate port that the web server is running on.(http://www.example.com:8080/content/created/by/extension.html) This is a problem for search engines.
Edit did I mention that I hate captcha?
(File Size: 115KB - Downloads: 125)