I am spinning a template for any wordpress based site that has some difficulties with load speed and I am searching for the easiest method to speed things on the code side first.
Because the site uses many "boxes" (like head lines, most sights, recent comments, publish each week, and so forth) that are used again in several pages, I figured in regards to a system to lessen the amount of queries produced by caching these sections 1 by 1.
It might work such as this:
- the code for each box is a function in
functions.phpincludes another file by having an array (say
$created) which records the final time a box was produced
- every function will first check
$created['someBox']: if under X the years have passed load
rendered_someBox.htmland give it back, else do full db processing, save
rendered_someBox.html, give it back increase amount of time in
- template files will just call these characteristics if needed
Is a smart approach in lessening load or will it increase the overhead of computer takes? How is this enhanced?
I would suggest using Wordpress' native
WP_Object_Cache class and processes:
And you might have a couple-level cache: cached HTML for presentation (for each "box"), and cached DB results (as some boxes might be different presentations of the identical data).