5

This is about that old trick of tacking a fake query argument onto the URL of a stylesheet (e.g., <link rel="stylesheet" type="text/css" href="http://www.example.com/site.css?v=123">) so that, when you change the stylesheet, it'll be reloaded by the users' browsers, since it looks like a URL that's not in the browser's cache.

So, the question: How can you do this in D7 where the stylesheets are specified in the .info files? I tried adding a query arg onto the entry in my site's info file -- stylesheets[all][] = site.css?v=123 but without any luck (the page rendering got very unhappy). Any ideas?

9

By default you can navigate to /admin/config/development/performance and select the Clear all caches button. Behind the scenes this will actually do what you describe by appending a new query-string to the CSS URL.

12

You can do this with drush

$ drush help cache-clear
Clear a specific cache, or all drupal caches.

Arguments:
 type                                      The particular cache to clear. Omit 
                                           this argument to choose from        
                                           available caches.                   


Aliases: cc

So you can do

drush cc css-js

and this will rescan the cached CSS and JS files, nuke them if they are stale, and generate a new key that gets appended to CSS and JS URLs.

  • 1
    This should be the accepted answer because this only clears the CSS and JS files, not the whole cache. – Goldentoa11 Jan 17 '14 at 14:18
  • I believe page caches should be cleared afterwards as well, otherwise cached pages would be referencing stale CSS/JS aggregate files. – Brian Dec 6 '17 at 16:06
5

Flushing the Drupal caches should take care of this issue for you.

0

You can see your changes made to your theme.info file by issuing the 'theme-list' cache clear Drush command:

$ drush cc theme-list

you can also add this line to theme.info to force rebuilding cache on every page load:

settings[clear_registry] = 1

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.