DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Stylesheets, as well as external JS files or images, are cached by browsers. This is mostly good because it saves bandwith, but it can be a pain when you’re upgrading your stylesheet and want your visitors to see the changes without having to manually refresh their cache.

Don’t know what cache is? This modern and gorgeous page says it all.

To get rid of browser caching on your stylesheet, just edit your header.php file, and use the code below to include your stylesheet:

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); echo '?'.filemtime( get_stylesheet_directory().'/style.css'); ?>" type="text/css" media="screen, projection" />

Thanks to Lyndi for this nice tip!



  1. how about native WordPress functions wp_register_style() and wp_enqueue_style() where You can specify version?

    PS better with echo get_stylesheet_uri()

  2. The Versions plugin takes care of this headache autimatically.
    Fixes version numbers for stylesheets and scripts automatically. WordPress plugin [Versions](http://wordpress.org/extend/plugins/versions/ “Versions Plugin at WordPress”). Works really good.

Leave a Comment

Your email address will not be published. Required fields are marked *