Skip to navigation

Manage the page cache

Pages can be created dynamically when they are requested, but it's more efficient to generate pages once and store them so that they can be used over and over again.  Cached pages can be served much more quickly than dynamic pages, so caching significantly reduces page load times.  

When Pyplate is installed, the cache is empty.  You can cache the pages in your site by clicking on 'Page Cache' in the Administration menu, and clicking on the button to 'Build the entire cache'.

Cached pages are static, meaning that they don't change once they've been created.  The downside of page caching is that it means pages can be out of date.  If you change your site's templates or CSS code, changes won't be visible until cached pages have been cleared.  Once the cache is cleared, the cache should be rebuilt again in order to carry on serving pages quickly and efficiently.

If you add a page or change a page title, you'll need to rebuild the page cache so that the new title shows up in site navigation.  Instead of caching the entire site, pages in a specific category and its subcategories can be recached.   

There are buttons to update cached versions of the sitemap file and the RSS feed, and a button to update a cached copy of the sidebar.  Pyplate updates these files automatically when you make changes to your site, so it's unlikely that you'll need to use these buttons often.  Sometimes if you make changes to template files you may need to recache the sidebar.  If you rebuild the entire cache, the sidebar and the XML files will be updated automatically.  

If you want to edit your site's templates or themes, it's important to empty the cache first, otherwise you won't see the changes you've made, you'll just keep seeing the same cached pages.

Auto-cache pages

Rebuilding the page cache causes spikes in the load on the CPU.  While the cache is being built, page load times may increase.  For small sites, this isn't much of a problem because rebuilding the cache takes a second.  With larger sites, re-caching every page could take a long time.  

Auto-caching means new pages are cached automatically, and you don't need to rebuild the cache once you've emptied it - the cache will refill as users browse your site.  When auto-caching is turned on, pages are cached when they are requested.  When a user visits your site, if the page isn't already in the cache, Pyplate will generate the page and save it so that it can be reused later.  

Auto-caching is turned off by default.  To turn it on, open /usr/lib/cgi-bin/index.py and look for the following line:

autocache = False

Replace False with the word True (Python is case sensitive, so don't forget to use a capital 'T').  

Note that while you're working on your site's CSS and templates, it best to turn off auto-caching.  If it's turned on, pages will keep getting cached, so you won't see the changes you're making to your site.  

Share this page:

Follow me