0

I'm developing theme and I want to make page cache of static pages in my WordPress theme (and basically I know how to implement it)

The problem is that when making theme - the first time when I "get any control" about what is happening is inside functions.php file of theme, and this file is loaded about 1 sec after request starts (before it is loading all wordpress functions stuff, I quess some sql - but I dont need that all as I'm using page cache, just want to render saved html - thats what is cache about to dont init functionality of page).

So the question is - Am I able to - from level of theme - take control of WordPress initialization before theme functions.php? - the best would be as soon as possible after request start

Why? Getting html from cache takes 0,05s in my case, and time from request start to functions.php is 1s so in sume it gives 1,05s that I could reduce to like 0,1s if I'm able to 'capture' request earlier.

I dont want to modify non-theme files like WordPress core files as many people will use this theme, but if there is no other way than maybe but I dont feel it would be good practice?

1
  • You want to implement caching in a theme? This is totally wrong. You can’t even know if you have write access in the theme directory. Write a plugin, that will be loaded earlier than themes.
    – fuxia
    Aug 14 '14 at 8:33
2
  1. You get as much control as any other plugin. if you need some code to be executed before any other you can't just include it in the theme and you will need the user to manually install it. Those files are reffered to "dropin plugins" and that is the best documentation I could find http://wpengineer.com/2500/wordpress-dropins/ (shame on the codex for not having that info)

  2. NO! leave caching to people that invested time to understand how to do caching properly and focus your efforts on design.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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