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
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
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)
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”
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
So, there are many sub-questions, i’ll try to address each.
Views Counter Problem – I could make this Value/function be ran using
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).
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).