51

From my experience as a Support Manager, I encounter a lot of “issues” with caching plugins in WordPress. It is good to understand what these plugins do (in general) and when to use them, and when not.

How WordPress Generates Pages

WordPress is a PHP/MySQL application. PHP stands for Hypertext Preprocessor. MySQL is a database system. PHP will take the code in WordPress, combined with code from your theme’s files (e.g. index.php), reads the database (containing your posts, widgets, plugins etc.) and merge all that into a plain HTML page.HTML being the “language” that browsers can read and display. This is a dynamic process, and will be performed each time a page is requested.

What a Caching Plugin Does

In general, a caching plugin will create a “snapshot” of all your pages to reduce the time required to generate an HTML page. Once a page has been generated by the process of reading a php file, get info (your posts, widgets etc) from the database, get and insert plugin info (e.g. “related posts”), once all the information is processed and a page is put together, a copy of the resulting HTML page will be stored in a folder on your server. This process is called caching.

When a browser requests a page, it will be served from those snapshots, from cache, thus reducing the time required to generate the page, and as such optimising the site load time. As soon as you change a page or posts content, or add a new post, the caching plugin will (re-)generate the cache for that page, so that future requests will reflect the updated version.

So What’s the Problem?

There really should not be a problem, unless you are still working on your site, developing, adding plugins and widgets, perhaps modifying CSS code or theme template files to change the functionality and looks of your site. Most, if not all of these activities do NOT trigger a cache plugin to regenerate all cached pages. So when a page is requested, chances are that the version that is displayed by the browser (the previous snapshot) does NOT reflect the CSS changes, widgets appear not to have been changed, plugins seem to malfunction etc.

What’s the solution

De-activating the caching plugin during the development stage of your site, can prevent these issues. In some cases, depending on the caching plugin you use, you might also have to clear the folder with the snapshots, the cached pages, but this requires you to access your server via ftp, and you need to be sure which files to remove. Be cautious, and always make a backup. Consult the plugin’s documentation on how to do this.

Being aware of this might save you a lot of headaches and confusion and “why is my page not updating, I can see the change in my WordPress backend, but not on the page!?”.

Every now and then, I get asked to do some customisations, and the one that regularly pops up is “I want to display posts in columns, {insert any number here} next to each other, just like in such-and-such (magazine) theme”. I created a piece of code that I am comfortable with, is easy to customise and adjust.

When another interesting request made it to my mailbox recently (“on my index page, I want to display 3 full width posts with the full content, followed by excerpts side by side”), I thought it was time to do a bit of polishing, and come up with a simple yet reusable solution.

I thought it might be worth sharing, so I decided to make it into a plugin, for the simple reason that it allows me to easily implement this solution on any site I am working on, without having to modify the theme template files (like functions.php, index.php or style.css).

So here it is, for you to enjoy and use as well. Note/disclaimer, it is by no means a “Formal Official WordPress Plugin” and I doubt it will make it to the WordPress plugin directory, but using a plugin is just easier “packing, shipping and handling”. Upon installation and activation, the plugin will not modify any theme files, database files whatsoever. If you don’t like it, or if it doesn’t work for you, simply delete the plugin folder, no harm done.

Read More→