I really want to use one of the Cache plugins so that I can serve up more Static pages on my WordPress theme/site. This is obviously the best performance upgrade you can do for a WordPress theme/site.

There is a few dynamic elements to my theme that have held me back from making the Leap to Static/cached pages.

I will outline these issues below and provide a possible way to solve each issue I have thought of so far.

The goal of this post is to either get better ideas/methods to handle the issues I explain or to get some reassurance that I am on the right track at the least. I am a PHP veteran of more then 12-13 years but have only been using WordPress in the past 1-2 years and so far I am really impressed with the capabilities, I am a total WordPress Fanboy now if such a thing exists lol!

Ok so the issues I have thought of so far when converting to cached pages...

Single Posts page

  1. Views Counter Problem - I have a function that will fetch a count value for a "View/hit Counter" on the Posts page to give an idea of the Posts Views for a user to see. These are not unique visitors but just a simple hit counter. I have created a separate MySQL table for these values, I am still trying to decide if I should continue with that or switch to use a Meta Field instead. Either way on a page view, the database value is fetched and increased by +1 on each page load. (Admin users views are not added.) The value is then showed on the page in the form of 988 Views

    Views Counter Possible Solution - I could make this Value/function be ran using Ajax. Once the new Cached/Static page is loaded, Javascript could then use Ajax to request and update the Views counter for that page. Does this sound like the best solution for something like this?

  2. Post Comments Problem - Using the default WordPress Comment System, every time a new comment is added to a post, it would require the Cached/Static page for that post to be re-built! From what I have seen, there is an option on the Caching plugins I have seen that will let you do just that, you can have it rebuild the page(s) every time a new comment is posted to it. This sounds good on paper but I can imagine it being a nightmare in a high traffic/active site where you might have multiple users commenting on the same article around the same time (all un-tested so I do not know)

    Post Comments Possible Solution - So for a solution to the Comments problem, I mentioned a solution above where you can set the Cache plugin to simply rebuild the Cached/Static page upon each new Comment. My concern was I am not really how well this will work in the long run. Now the other possible solution that I see being used more and more is to use a Javascript solution like Disqus Comments or a similar solution. For a long time I really was against this as I wanted all my Comments to not rely on any third-party for my comment system. I am still kind of on the Fence about this issue but have switched to using Disqus comments on my site and so far it's working out fairly good. I am open to other possible solutions though? Or do you think this is really the way to go?

Site-wide Sidebar

  1. Sidebar Recent Articles Problem - I have Tabs in my Sidebar that are shown site-wide across every page on the site...one of the Tabs loads the 10 most recent posts on the blog, since this is shown on every page of the site, once a new article/post is added, it would require that every Cached/Static page on the site be re-built to reflect the addition of new posts in this "Most recent posts list"

    Sidebar Recent Articles Possible Solution - Again I think I have come up with a good possible solution. I could use Javascript and Ajax to load this content into the Cached/Static pages so they would not ALL have to be re-built so often but could still show the most recent posts.

    Does this sound like a good solution? Or more importanctly, can you think of another better or alternative solution to this problem?

Without getting my hands too dirty yet, this is all the possible problems I can see so far with converting my theme to be Cache/Static Friendly


I just thought of another issue to think about. All Tag/Category as well as user pages will need to be updated every time a post is added that fits into that pages list of posts. I assume this must be a feature of the Caching plugins already I would imagine though

  • 2
    Why Views Counter must be correct every request? What will happen if it shows 5-10 views missing before cache update? Jul 20, 2012 at 10:50

2 Answers 2


So, there are many sub-questions, i'll try to address each.

Views Counter Problem - I could make this Value/function be ran using Ajax. Once the new Cached/Static page is loaded, Javascript could then use Ajax to request and update the Views counter for that page.

Totally agree: added benefit: loading it via ajax when "important" content has finished loading is the way to go. Do everything you can to reduce the page loading time. I'd definitely go with Ajax on this one.

Post Comments Problem

I doubt this will every be a big issue. But again: ajax. Load comments apart from the "main" content. Have it push new comments regularly (just like Stackoverflow does, or twitter.com, warning the user and waiting for his click to refresh the comments stream).

Site-wide Sidebar

I would use another plugin: WP Widget Cache, which allows you to set the caching time for each widget in your sidebars, and works well with the usual caching plugins. In your case, just set "0" for no caching for those widgets, or, "10 minutes" (better than no caching at all).


If you are using w3 total cache then you can exclude certain pages like your sidebar from being cached.

Go to WordPress Admin > Performance > Page Cache and change the section under never cache these pages

Never cache pages W3 Total Cache
This example shows sidebar files in a theme are excluded from the cache.

You can also set shorter expiry time on your cached pages for example 5 or 15 mins. The cached pages most affects people who are first time visitors and don't have a session cookie. As the 'most requested' cached view of page is shown to first time, anonymous visitors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.