How to clear cache on every page load?

I am doing CSS & JS theming and currently having to manually clear cache (using devel module) every time and then reload the page again to see my changes?

How do I do it so that in every page load cache is cleared?

  • @Nikhil - Your solution works too. Thanks. I ended up just using areynolds idea as it was easier for this specific need.
    – drupalmav
    Oct 25 '12 at 7:39

As long as you don't have JS or CSS aggregation turned on, you shouldn't have to clear cache to see your changes to existing files. You can see this settings by going to;


If you are adding new CSS or JS files, you'll probably have to clear cache to register them with the theme system.

If you really want to clear cache on every page load, you should create a custom module that implements hook_init() and runs drupal_clear_css_cache() and drupal_clear_js_cache() (or any other cache clearing functions you may want), but this should be unnecessary.

  • 1
    And it s not probably cached in Drupal but in browser, a simple Ctrl F5 in browser will do.
    – GoodSp33d
    Oct 22 '12 at 7:06

If you disabled caching in Drupal (Performance) and still files are not reloaded, it's probably cached by your web browser.

Some web browser can force the cache reload by holding Shift.

In Chrome internal caching can be disabled in DevTools settings (F1 once you open Developers Tools), then: Disable cache (while DevTools is open).

enter image description here


This is not a perfect solution. But you can use this in dev stages

Copy/Paste this code in your themes template.php

function YOURTHEME_preprocess_page(&$variables) {
  global $base_root
  include_once $base_root.'/includes/bootstrap.inc';

Try and let me know the status.

  • This is terrible for performance. You are much better to simply un-preproccess the JS and CSS for development.
    – wiifm
    Oct 28 '12 at 0:08
  • @wiifm OP asked for it, and as i stated This is not a perfect solution. But you can use this in dev stages
    – niksmac
    Nov 25 '15 at 7:17

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.