3

Is it possible to let Drupal refresh one particular cached page?

Currently, one page of our site shows some dynamic table data by Table Wizard. After some update in MySQL table, the page does not fresh.

I assume it's due to the site caching is on (Caching mode is set to: Normal). For anonymous users, the page refresh sort of 60 minutes later.

Instead of clearing the whole site's cache, is there a way to let Drupal refresh only one page? Thanks!

ohho
  • 50,879
  • 75
  • 256
  • 383

1 Answers1

1

One method to "let Drupal refresh one particular" page is to just keep it out of the cache.

The cacheexclude module is designed for this. Just tell it the page(s) you want kept out of cache.

If you don't want to install another module, you can override hook_init():

mymodule_init() {
  $path = drupal_get_path_alias(request_uri());
  if ($path == "<do not cache path>") {
    $GLOBALS['conf']['cache'] = FALSE;
  }
}
keithm
  • 2,813
  • 3
  • 31
  • 38
  • Will this work inside hook_init if the page is already in cache? I think hook_init is never invoked if page is already in cache. If I'm correct about that `hook_boot` may be a better place to do this if serving from cache has to be disabled only for some requests based on some logical condition. – rineez Jan 18 '19 at 04:46