9

Using Drupal's standard cache system, is there a way to clear the cache for a node or url without clearing the entire cache (which slows down the whole site)?

6

The module Cache actions provide very fine grained control over your cache clearing.

Unfortunately, whether it will solve your exact problem depends on how this particular url is built up. In case it doesn't do exactly what you want, it's codebase would still be an excellent start for building more exactly what you need.

| improve this answer | |
6

Yes you can do it programmatically also.

In this example we clear the front page cache :

$url = url('<front>',  array('absolute' => TRUE));

cache_clear_all($url, 'cache_page');

Drupal stores the paths as CID in table and in above example we are providing front page URL as CID as a first argument in the function and if you define the CID, it is mandatory to define the second argument $bin in the function, which is like from which table you want to delete cache. As we have to delete a single page, so its present in cache_page which holds cache for pages.

| improve this answer | |
3

There is a module for that: Flush page cache. Here is a quote about it (from the module's project page):

Easing the pain when you need to flush ... Drupal's cache.

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.

| improve this answer | |
0

Another option would be to create a form and use the function cache_clear_all on the url whose cache you want to clear. I found an example of it use here

| improve this answer | |
0

A little late to the party here, but, the Cache Expire module is probably what you're looking for. It gives you really fine-grained control over how caching is utilized for multiple entity types (if you use the 2.x version of the module).

Either version of the module however gives you access to a Rule action "Clear URLs from page cache". So, you can specify whatever events and conditions are necessary for the rule to fire, and then the URLs you specify will get wiped out. Hope this helps.

| improve this answer | |
-1

cache clearing stuff can be done simply by downloading drush module from http://drupal.org/project/drush

terminal->your drupal directory

write the command drush cc

It would return you with

[0] : Cancel
[1] : all
[2] : drush
[3] : theme-registry [4] : menu
[5] : css-js
[6] : block
[7] : module-list
[8] : theme-list
[9] : registry
[10] : views

So you can select which ever thing you want to clear..

If you want to do clear cache from the drupal website then you could install and enable the module http://drupal.org/project/admin_menu It provides a home icon on your drupal sile and would give you a menu list where you could go for cache clear stuff....

| improve this answer | |
  • 1
    He is asking about advanced, custom cache mechanism – Codium Apr 5 '13 at 12:15
  • You can do drush cc views for example where views can be any type in that list. – Yzmir Ramirez Oct 24 '16 at 20:43

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.