0

I have a view that lists new content of a specific content type. It displays the "new" or "updated" tags (Content: has new content). The problem I am having is that when following the links to view the individual nodes, and then hitting the back button, the browser serves up the listing from disk cache, with out of date "new" tags. I'd like to add a no-store header to the listing, either by adding a meta tag or html header, but cannot find an appropriate hook to alter the views page view.

It seems inappropriate to add it to a hook as generic as hook_page_build.

Here is my current solution:

function MY_MODULE_page_build(&$page) {
  if (function_exists('views_get_page_view')) {
    $view = views_get_page_view();
    if ($view && isset($view->name) && ($view->name == 'my_view_name')) {
      $page['content']['modify_header']['#attached']['drupal_add_http_header'] = array(
        array('Cache-Control', 'no-store', TRUE),
      );
    }
  }
}

If its relevant, my view is defined in a feature.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.