How to clear only the front page cache? I want to clear the front page cache when a new node is added.
Drupal 6 and 7 use the URL of the page as the cache ID (the
drupal_page_set_cache()). This should work.
$url = url('<front>', array('absolute' => TRUE)); cache_clear_all($url, 'cache_page');
You will need to adjust the logic a bit if you can access the site through multiple URLs.
Give a try to Flush page cache module:
Flushing Drupal's cache on a large site can feel like you're waiting to takeoff on the tarmac at JFK. The delay comes from the fact that when you clear Drupal's cache, it clears everything. Most of time you just want to flush the cache for specific object on a page.The 'Flush page cache' module solves this problem by flushing only the cached objects for a single page. Additionally, you can define custom objects and cache tables to be cleared on specific pages
- You have nodes nested in views nested in a panel page. You've edited a node that's displayed on this page, but you want the change to be seen immediately.
- You have a large team of non-technical content editors who frequently run into the scenario above and you want to give them an easy, one-button solution to their content being updated in the lists they manage.
- You've just cleared the entire website's cache through the normal means and for whatever reason, a few pages are rendered and cached in a broken state.
Using drush is the fastest way to clear cache.
// clear all
drush cc all
// individual caches to clear
drush cc theme-registry
drush cc menu
drush cc css-js
drush cc block
drush cc registry
drush cc views
I found a blog post which shows how to clear a single page with drush. disclaimer I have not tried this method personally. Clear a single page cache drush
drush sqlq "DELETE FROM cache_page WHERE cid = 'http://example.com/'"
or with using a drush alias
drush @your_alias sqlq "DELETE FROM cache_page WHERE cid = 'http://example.com/'"