I am working in drupal 6. I know that saving any node clears cache but is the same with views? I am experiencing this issue. I would like to know how to prevent it. Thank you.


If we inspect views_ui_edit_view_form() we can see the following #submit handler being assigned:

  $form['buttons']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#validate' => array('views_ui_edit_view_form_validate'),
    '#submit' => array('views_ui_edit_view_form_submit'),

Drilling further down into views_ui_edit_view_form_submit() it becomes clear which caches are affected by saving a view:

  // Make sure menu items get rebuilt as neces

  // Clear the views cache.
  cache_clear_all('*', 'cache_views');

  // Clear the page cache.

  // Remove this view from cache so we can edit it properly.
  views_object_cache_clear('view', $form_state['view']->name);

In summary, these are the caches that get cleared when a view gets saved:

  • menu
  • views
  • block
  • page

In addition, the menu rebuild triggers the following hooks:

  • hook_menu()
  • hook_menu_alter()
| improve this answer | |
  • Hi, exactly page cache I am interested in. Any suggestion how to prevent that? Thank you. – loparr Oct 3 '15 at 17:35
  • @loparr Why do you want to prevent the page cache from being cleared? – Fabian Iwand Oct 3 '15 at 17:54
  • I dont see a reason, why should be page cache for all site cleared while I work on 1 view, that I do not even use anywhere. – loparr Oct 3 '15 at 17:58
  • In my opinion it's not worth the trouble. You'd have to replace the submit handler completely and implement your own way of rebuiding the menu (as that clears the caches as well). By overriding you would also miss updates to the original submit handler. Really, don't. – Fabian Iwand Oct 3 '15 at 18:55

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.