I use simple redirect user inside template.php with the following code:

if ( isset($_GET['abc']) && $_GET['abc'] == 1 ) {

Is it possible to redirect to the page even with caching turned on? It seems that if the page that I want to redirect from is already cached, the template.php file does not fire.

  • in which function do you use that code? – kiamlaluno Oct 11 '15 at 19:35
  • @kiamlaluno in preprocess_page – loparr Oct 11 '15 at 19:44

Usually no. Not like that.

Caching systems are created to serve content with as minimal as possible PHP execution. If you use varnish, nginx or similar cache, or Boost module, you ay even not have any PHP executed at all. And even if some parts of PHP are executed, theming layer is usually omitted, because logic shouldn't be there - and if logic shouldn't be there, then that's exactly the part that is (or should be) safe to cache.

So first, try to move logic from template to some module, and second - learn about the caching system you are using, and how to add exceptions to it (if just moving the logic does not fix it for you already).

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.