• Subscribe to the RSS feed! RSS icon
  • Subscribe by Email
  • home
  • blog
  • dev
  • Recent Posts

    • Eight years of PHP
    • Learning English
    • Saturday night hack - coords
    • When a package update goes wrong
    • Frontend testing with phantomjs and casperjs
    • Gnucash 4.2 with SQLite3 on GNU/Linux
    • A monkey with a banana
    • 2012 - 'twas a fine year!
    • Let's learn Astronomy!
    • Unit testing Zend Framework 2 modules
  • Tags

    php, about, random, framework, zend, example, ubuntu, zend framework, blog, site, python, book, conference, linux, me, wordpress, apache, hack, hex, introduction, lamp, longboard, open source, review, script, setup, signals, zend framework 2, ape, community, contributing, dbus, dojo, events, life, mysql, netbeans, pidgin, plugin, pyqt
  • Categories

    • Blablabla
    • Development
    • Free time
    • Places on the web
    • Programming
    • Software
    • Uncategorized
  • Archives

    • April, 2013
    • March, 2013
    • February, 2013
    • January, 2013
    • September, 2012
    • August, 2012
    • July, 2012
    • June, 2012
    • February, 2012
    • January, 2012
    • December, 2011
    • November, 2011
    • October, 2011
    • September, 2011
    • August, 2011
    • July, 2011
    • May, 2011
    • April, 2011
    • March, 2011
    • January, 2011
    • December, 2010
    • November, 2010
    • October, 2010
    • July, 2010
    • June, 2010
    • April, 2010
    • February, 2010
    • January, 2010
    • December, 2009
    • November, 2009
    • October, 2009
    • August, 2009
    • May, 2009
    • March, 2009
    • February, 2009
    • January, 2009
    • December, 2008
    • November, 2008
    • October, 2008
    • September, 2008

Zend Framework full page cache tips

by Robert Basic on February 11th, 2012
When I started rewriting this blog, I knew from start that I want to use Zend Framework's full page caching, as, I think, that's the best cache for this purpose. Not much going on on the front end, much more reads than writes, no ajax or any other "dynamic" content. While implementing the cache, I ran into two issues.

The first problem was that the cache files were created, but they were never valid - on each request a new cache file was created. It was a noob(ish) mistake - I had two calls to Zend_Session::startSession() in my code, which made the session ID always to change which made the cache validity test to fail. Removed the second call and all was well. Or so I thought...

I moved the code to staging to run some final tests before pushing it live, but the cache started failing again. This time the cache files weren't even being created! The same code works on my machine, fails on staging. The only difference was that I had turned off the loading of Google Analytics in the development environment. But... that can't be it, right? Wrong. On every request the values of the GA cookies are different. The full page cache has a set of settings which dictates what variables are taken into account when creating an ID for the cache: make_id_with_xxx_varialbes where "xxx" is one of get, post, files, session, cookie and by default all are set to true. Setting make_id_with_cookie_variables to false made the cache to disregard the always changing GA cookies which made the cache start working again.

So, if Zend Framework's full page cache starts failing for you, check the contents and behaviours of all the variables - get, post, files, session, cookie - and play around with the cache settings until it starts working again.

Happy hackin'!
Tags: zend framework, full page cache, caching.
Categories: Development, Programming.
Robert Basic © 2008 — 2013
Design & graphics by: Livia Radvanski
Coded by: Robert Basic
Home page last updated on November 30th, 2009.
Frameworks used: Zend Framework, Dojo, 960 Grid System