Post Pic

Prevent WordPress stylesheet from being cached

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!

Related Posts

Related Posts

No related posts.

Leave a Comment

* Name, Email, Comment are Required