Faster, faster, faster! That’s the overriding mantra of the day when it comes to website load speed.
There are hundreds of factors that affect the loading speed of a website. This is complicated further if you’re running a dynamic CMS like WordPress.
Caching, and caching plugins for WordPress in particular, are often used to help out. We can apply caching to many things and it’s a wonderful thing when used correctly.
But there is 1 type of caching that destroys lives, breaks families apart, and sucks the joy of life from everyone it touches: Page Cache.
What is Page Cache?
The name is a little self-explanatory, but it causes a lot of trouble. Here’s a simple way to look at it:
When Visitor ‘A‘ requests a page, the website will build it and return this page ‘content’ to the visitor’s browser. With Page Cache running, this page content is saved so that it doesn’t need to be rebuilt if someone else asks for it. Then, when visitor ‘B‘ comes along and requests the same page, the page cache simply sends out the previously cached content (without having to rebuild anything).
This sounds absolutely wonderful, right? Serving a page from cache will completely by-pass all the processing that goes into making a page load. Fan-freakin’-tastic!
Page Cache is great for static content.
In the big, wide world of the web, content can be broken up into 2 main types:
Static content is that which doesn’t change. A trivial example of this is an image. Images don’t magically change from 1 request to the next. If you request the same URI for an image, you’ll get the same image every time. It’s static – unchanging. (note: static is unchanging… it doesn’t mean “never” changing)
Dynamic content is that which is constructed at the time of the request. Depending on various factors and variables, the content may change. Not all the time, but since it’s dynamic, it has every right to do so.
How does this relate to page caching? Page caching is a way of forcing dynamic content to be static.
WordPress is, by definition, dynamic. The content of each and every page is built at the time of request from the visitor.
That’s a lot of work. But that’s the way it is. This is the price we pay for a site that is easily customizable.
So can you imagine what will happen when we try to force dynamic websites to be static? That is, when we try to force dynamic content to be static?
Page Cache is not so good for WordPress
Yes, you heard it here first. Page Cache isn’t good for WordPress. Now go and tell all your friends.
If there is any content on a page that must be unique or specific to a given visitor, then you cannot use Page Cache.
Read that line again. This is really important.
Here are some of the consequences of ignoring this principle:
- Unique, per-visitor, dynamic content will not work. And if it does, it’ll be erratic at best.
- Any plugins or themes that require unique, dynamic content display/processing will break. (it’s not the fault of the developer)
- Things on your site that you don’t even realise are dynamic and unique will break and you may not even notice.
Are you seeing the trend?
Page. Caching. On. WordPress. Will. Break. Things.
Why do WordPress plugins offer page caching if it breaks things?
Great question! Here’s another: you have the option to go out and score some crack. Why don’t you?
Having the option to do something doesn’t mean it’s right for you.
There are certain scenarios where page caching will work well i.e. if the page content is static – it’s perfectly ok to use WordPress to build static websites. If this is the case for you, then by all means, throw page caching at it.
How can I speed up my site if Page Caching doesn’t work?
There are 1,000s of resources to help answer this question and we’re not going to dig into such a huge topic here.
Page Caching is just 1 type of caching. Unfortunately it gets rolled up with all the other types of caching, and many site admins become defensive of the idea that caching might be a problem.
I use page caching! What should I do with it?
You probably already know the answer to this. But there is a lot of resistance to turning off page cache, I know, so here’s the question you need to ask:
Do I have, or think that I have, any dynamic content on my site which should be unique to individual site visitors?
- Yes: Turn off your page cache
- No: Keep it on, or turn it off just in case.
“I disagree, Page Caching works on my site”
If page caching works on your site, then great. That doesn’t mean that this article is wrong. It means that you’re lucky.
Your plugin/theme soup isn’t affected, as far you can see, by page caching. Perhaps your site content doesn’t need to change for each visit/visitor and you essentially have a static site.
Comments, Questions, Arguments?
We can imagine a lot of folks wont like this – especially premium caching plugin developers. But this is unfortunately the reality.
Note: no plugins were harmed in the making of this article.