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
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?
-
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
-
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
UPDATE
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