How to truly disable drupal cache
Drupal, like most CMSes uses cache intensively to speed things up. In a production site that is exactly what you what. However when developing, cache can cause you much pain.
If your an expert in drupal you probably already realized when you need to clear the cache in order to see changes and when not too. the developer module even makes it quite easy to do. However for me, and I am quite sure to quite a lot of other people it is not that clear.
"Wait", you might say. "Drupal has a disable cache setting". You would be right to say that. Only it doesn't completely disable the cache, only part of the cache, namely the page caching. To truly disable cache you need to do a bit of a hacking to the cache code. Yes I know they say to never hack core (cache is part of the core drupal release). for me this was worth it. I figure as long as you remember its there and don't use it in production you should be fine. The following piece of code needs to be added in include/cache.inc. There are two functions there that you need to edit:
cache_getcache_set
In cache_get place the code right after the global $user. In cache_set place it at the start of the function. Here is the code that you need to add.
if(variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED) {
return 0;
}
Kudos for this hack goes to Rolf van der Krol. Cheers mate.
November 25th, 2009 - 03:58
Hey, thanks for this tip. Not sure if this was where I originally found it, but I’ve been using it for a while now and haven’t had any problems until recently. I was a bit mystified as to why I couldn’t export a CCK content type; it turns out it was because of this. Basically this hack breaks the multipart form system: Drupal looks for a cached form, and because of this hack thinks that the lookup failed, and draws the conclusion that this is a fresh presentation of the form.
I’m surprised I haven’t run into other problems because of this.
Anyway it did seem to make things speed up a bit, but I guess I’ll unpatch it.
Thanks!
November 25th, 2009 - 17:43
Did I say speed up? Well you know what I meant. Cheers