Alister Cameron // Blogologist

Changing the world. One blog(ger) at a time.

WordPress Plugin: CSS Cache Buster

ball chain Wordpress Plugin: CSS Cache BusterThanks to Matt for prodding me to take the CSS cache buster code I posted about a couple of days ago, and turn it into a filter.

I decided to go one better and make it a plugin, for those who are intimidated by code or just pressed for time.

So here’s the current readme, which is short and to-the-point (so unlike me!):

CSS Cache Buster does one very simple but very powerful thing: it ensures that your WordPress blog delivers the very latest version of your CSS stylesheet to your visitors, no matter how often or how rarely you edit your CSS.

You no longer need to worry that you’ve made a CSS change that others won’t see because of caching issues at their end.

Technically, this plugin automatically appends a last-modified date/timestamp to the end of your stylesheet url.

And since this feature is applied as a filter, you don’t have to touch your theme files. It just works.

Simple!

If that makes sense to you — and if you’re a developer I sure hope it will — here’s the big fat download button:

download Wordpress Plugin: CSS Cache Buster

This plugin live here, and on this page:

http://wordpress.org/extend/plugins/css-cache-buster/

Installation

The CSS Cache Buster plugin is installed in the standard way:

  1. Download the plugin and unzip the contents (the php file and the readme.txt file)
  2. Upload `css-cache-buster.php` to the `/wp-content/plugins/` directory
  3. Activate the plugin through the ‘Plugins’ menu in WordPress
  4. That’s it! Nothing else to do. Breathe a long sigh.

Changelog

  • 12 Sep. 2008 — v0.5 beta
    Initial release
 Wordpress Plugin: CSS Cache Busterright;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=057a23f3-73e2-4216-a4d8-4faa3d62a567" alt="Reblog this post [with Zemanta]">

32 Comments

Note: Commenter website links are not no-followed, in case
you were wondering... I believe in rewarding commenters!

  1. Posted 6 years, 1 month ago // Permalink

    Nice! I am about to go to sleep, but I’m going to download it and put it on my website tomorrow.

    Question – do you think it will work in conjunction with the WP CSS plugin?

  2. Posted 6 years, 1 month ago // Permalink

    hi. Thanks for plugin

    perfect.

    Regards

  3. Posted 6 years, 1 month ago // Permalink

    a thoughtful plugin. I am going to get it! Thanks!

  4. Posted 6 years, 1 month ago // Permalink

    This is a neat idea, but not very effective if you’re using WP (Super) Cache, or other caching plugins. :(

  5. Posted 6 years, 1 month ago // Permalink

    @Scribu – thanks for the comments about the caching plugins. I have no problem with the conflicts between this plugin and other caching plugins. They are trying to do the exact opposite of this plugin.

    For my kind of feature to work with these plugins would require regex filtering on their static/cached files, or a re-caching feature so new cache files are created when a CSS file update is detected.

    Either way, it would be up to the individual plugin author to write this sort of feature into his/her plugin.

    For sure, installing my plugin can only help, not hinder. And — wondering out loud — how many people actually use these cache plugins anyway? I tried for a while, but solved all my problems with a beefier server.

  6. Posted 6 years, 1 month ago // Permalink

    Hello Alister,
    i have a small changes for your plugin. In WP2.6 is it possible to change the wp-content-folder for more security and you can use the new constants. Here my code.

    if ( !defined( 'WP_CONTENT_DIR' ) )
    define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );

    function css_cache_buster($info, $show) {
    if ($show == 'stylesheet_url') {

    // Is there already a querystring? If so, add to the end of that.
    if (strpos($pieces[1], '?') === false) {
    return $info . "?" . filemtime(WP_CONTENT_DIR . $pieces[1]);
    } else {
    $morsels = explode("?", $pieces[1]);
    return $info . "&" . filemtime(WP_CONTENT_DIR . $morsles[1]);
    }
    }
    else return $info;
    }

    add_filter('bloginfo_url', 'css_cache_buster', 9999, 2);

    Nice idea and plugin; i hope you nejoy my small changes.
    best wishes Frank

  7. Posted 6 years, 1 month ago // Permalink

    Frank,

    Thanks for that.

    I like it and I’ll commit that change.I was not up on that latest security enhancement, but it makes a lot of sense.Thanks for the improvement :)

    -Alister

  8. Posted 6 years, 1 month ago // Permalink

    Many thanks for plugin! This is something what did not suffice for me.

  9. Posted 6 years, 1 month ago // Permalink

    @Alister Cameron: Welcome.

  10. Posted 6 years, 1 month ago // Permalink

    For my kind of feature to work with these plugins would require regex filtering on their static/cached files, or a re-caching feature so new cache files are created when a CSS file update is detected.

  11. Posted 6 years, 1 month ago // Permalink

    The many thanks for the work! I the worshipper Of wordPress, and included your site in survey on my blog. Regards from the Ukraine!

  12. Posted 6 years ago // Permalink

    So, I wanted to add a hint about the WP_CONTENT_DIR issue in WordPress 2.6, too, but fortunately Frank beat me to this. Alas, loads of plugins haven’t caught up to the directory structure changes in WP 2.6.

  13. Posted 6 years ago // Permalink

    When you dosen’t like the version with constants, use the function content_url($path = '').
    This is a little bid smaller, works only at 2.6 and bigger.
    see here: http://wpengineer.com/wordpress-return-url/

    Best wishes

  14. Posted 6 years ago // Permalink

    Thank you very much for plugin. Thank you for sharing such a cool idea. Cheers!

  15. Posted 6 years ago // Permalink

    This plugin is great! Please keep up development! I will definitely be featuring it in my blog at some point.

  16. Posted 5 years, 11 months ago // Permalink

    does this still work with the latest 2.6.3 version of wordpress? I can't see it working, my files still are called style.css and served like that to the browser, shouldn't I see the appended timestamps?

  17. Posted 5 years, 11 months ago // Permalink

    Thanks for this CSS plugin for WordPress

  18. ovidiu
    Posted 5 years, 11 months ago // Permalink

    anyone?

  19. ovidiu
    Posted 5 years, 11 months ago // Permalink

    btw. this seems only to take the theme default style sheet into account, can it be modified to check all .css files? even those loaded by plugins?

  20. Posted 5 years, 10 months ago // Permalink

    Is this plugins work for WP 2.6.5 ?

  21. TT
    Posted 5 years, 10 months ago // Permalink

    It’s a nice piece of code, but wuth one huge typo which renders it lame:

    The variable “$morsels” gets set on line 19, but when used on the next line it is spelled “$morsles” (note the L and the E changing place!)

    Fix it and it’s a hit!

  22. Alister Cameron
    Posted 5 years, 10 months ago // Permalink

    Thanks to suggestions and such. All have been considered and/or incorporated in the update that’s just come out!

  23. Posted 5 years, 9 months ago // Permalink

    So, I wanted to add a hint about the WP_CONTENT_DIR issue in WordPress 2.6, too, but fortunately Frank beat me to this. Alas, loads of plugins haven’t caught up to the directory structure changes in WP 2.6.

  24. Grateful Anon Guy
    Posted 5 years, 7 months ago // Permalink

    That is a BRILLIANT plugin, really. Simple but works gr8. Saves me all the time swearing at the css that never updates and the Googled answers that never were as effective… Thanks A Billion!

  25. Posted 5 years, 5 months ago // Permalink

    @Scribu – thanks for the comments about the caching plugins. I have no problem with the conflicts between this plugin and other caching plugins. They are trying to do the exact opposite of this plugin.

    For my kind of feature to work with these plugins would require regex filtering on their static/cached files, or a re-caching feature so new cache files are created when a CSS file update is detected.

    Either way, it would be up to the individual plugin author to write this sort of feature into his/her plugin.

    For sure, installing my plugin can only help, not hinder. And — wondering out loud — how many people actually use these cache plugins anyway? I tried for a while, but solved all my problems with a beefier server.

  26. Gunther
    Posted 5 years, 4 months ago // Permalink

    Hallo! After Ungrade to WP 2.8
    http://www.code-styling.de/deutsch/probleme-mit-wordpress-28-loesen
    proposed to write in the confip.php:
    define(’COMPRESS_CSS’, false);
    But will this work fine with your CSS Cache Buster?

    Thanks for your work and help

    Gunther

  27. Posted 5 years, 3 months ago // Permalink

    I just wanted to say that I use your plugin extensively and it’s great! Thank you.

  28. Posted 5 years ago // Permalink

    This plugin IS exactly what I need thank you so HUGE, I’ll blog about this plugin & link to your page! Oh I am so excited because now I don’t need Proxy sites to display the actual interface after I made many changes on my Style.css file!
    :)

  29. Posted 4 years, 5 months ago // Permalink

    Thank you for the plug! It is very urgent for absolutely any version of WordPress.
    Frank, thanks for the helpful comments!

  30. Posted 4 years, 4 months ago // Permalink

    CSS Cache Buster does one very simple but very powerful thing. It ensures that your WordPress blog delivers the very latest version of your CSS stylesheet to your visitors, no matter how often or how rarely your edit for CSS.

  31. Posted 4 years, 4 months ago // Permalink

    hmmm, love the plugin, but I have multiple stylesheets and this only seems to work for the main stylesheet referenced by ‘stylesheet_url’. Any thoughts to adapting this to the ”stylesheet_dir’ variable?

  32. Posted 3 years, 8 months ago // Permalink

    Thanks for the big fat download button buddy!

33 Trackbacks/Pingbacks

  1. t see because of caching issues at their end. Technically, this plugin automatically appends a last-modified date/timestamp to the end of your stylesheet url. And since this feature is applied as a filter, you don’t have to touch your theme files.Plugin Page

  2. WP-Universe creates a blog universe based on categories of a WordPress blog. WP Smiley Switcher With this plugin you can choose a smiley pack from the settings / options in admin or simply choose your own smiley pack directory.CSS Cache BusterAlways deliver the latest version of your CSS stylesheet to browsers. All caching problems solved. Continue Reading Weblog Tools Collection: WordPress Plugin Releases for 09/13

  3. WP-Universe creates a blog universe based on categories of a WordPress blog. WP Smiley Switcher With this plugin you can choose a smiley pack from the settings / options in admin or simply choose your own smiley pack directory.CSS Cache BusterAlways deliver the latest version of your CSS stylesheet to browsers. All caching problems solved. Filed under: Darker Than Black, Monster

  4. WP-Universe creates a blog universe based on categories of a WordPress blog. WP Smiley Switcher With this plugin you can choose a smiley pack from the settings / options in admin or simply choose your own smiley pack directory.CSS Cache BusterAlways deliver the latest version of your CSS stylesheet to browsers. All caching problems solved.

  5. WP-Universe creates a blog universe based on categories of a WordPress blog. WP Smiley Switcher With this plugin you can choose a smiley pack from the settings / options in admin or simply choose your own smiley pack directory.CSS Cache BusterAlways deliver the latest version of your CSS stylesheet to browsers. All caching problems solved.

  6. - как-то не очень прельщает. Какое-то время я так и делал, но потом забил. Сегодня мне очень кстати попался плагин для WordPress под названиемCSS Cache Buster

  7. cached version (which might display a borked page), this tutorial and the subsequent plugin might be for you. Alister explains the issue in detail, provides a tutorial on how to acheive the results and then with some prodding from Matt, comes up with aplugin the get the same resultwhich does not require any modification of code.

  8. CSS Cache Buster

  9. WP-Universe creates a blog universe based on categories of a WordPress blog. WP Smiley Switcher With this plugin you can choose a smiley pack from the settings / options in admin or simply choose your own smiley pack directory.CSS Cache BusterAlways deliver the latest version of your CSS stylesheet to browsers. All caching problems solved.

  10. CSS Cache Buster

  11. WP-Universe creates a blog universe based on categories of a WordPress blog. WP Smiley Switcher With this plugin you can choose a smiley pack from the settings / options in admin or simply choose your own smiley pack directory.CSS Cache BusterAlways deliver the latest version of your CSS stylesheet to browsers. All caching problems solved. BloggBroker http://www.BloggBroker.com

  12. Ärgernis – die CSS-Datei wird also gecacht. Was, wenn wir an dieser Änderungen vornehmen – der User dieser aber nicht mitbekommt, weil er noch eine alte, gecachte Version benutzt? Abhilfe hier: einWordpress-PluginDie CSS-URL wird dahingehend modifiziert, dass sie immer einen Zeitstempel (der letzten Änderung) angehängt bekommt. Änderung des CSS -> neuer Zeitstempel -> neu CSS-URL Simpel, praktisch, effizient.

  13. это и может получиться чуть лучше).CSS Cache Buster- странная шутка, которая нужна, чтобы удостове

  14. [...] Plugin Homepage » [...]

  15. [...] Comments [...]

  16. [...] 达人Matt给他提了个建议,让他使用filter来实现这个,这样,每个主题都会因为这个而受益。结果这个小老外就去写了一个插件,叫做CSS Cache Buster(点击链接,查看插件页面,下载插件)。 [...]

  17. [...] очень кстати попался плагин для WordPress под названием CSS Cache Buster. Он делает очень простую вещь – считывает дату [...]

  18. [...] = new curvyCorners(settings,’lightBoxOuter’); gsmh.applyCornersToAll(); 2 Clips WordPress Plugin: CSS Cache Buster Submitted by Raavi 19 hours [...]

  19. [...] Nur eine Idee … [...]

  20. [...] If you are a theme developer, or even a constant tweaker, then you may have found that your visitors don’t always see your CSS changes due to caching. Alistair Cameron has released a plugin to resolve the CSS cache problem [...]

  21. [...] WordPress Plugin: CSS Cache Buster cssのキャッシュ問題をクリアしてくれるプラグイン (tags: wordpress plugin css cache) [...]

  22. [...] Спросите что за ахинея, как он может быть не свежим? А оказывается, что так иногда бывает. Так в ряде случаев браузер при обращении к сайту использует файл CSS хранящийся у него в кеше, и лишь при обновлении страницы загружает новый “свежий” файл. Это я узнал, сегодня, когда в течении целого дня правил шаблон моего блога. Есть два способа поправить эту ситуацию. Первый, это каждый раз после редактирования файла добавлять к концу имени восклицательный знак и несколько цифер, например: …/style.css?123 однако такой способ весьма не удобен при очень частом редактировании файла стиля. Представляю вам второй способ и собственно плагин для WordPress который автоматически подставляет считанную дату с файла стиля к концу онного. Ð’ результате чего, я и посетители будут получать самую актуальную версию файла стилей, что обеспечит практически моментально применение сделанных изменений. Перейти на страницу с плагином CSS Cache Buster можно по этой ссылке [...]

  23. [...] Takayuki Miyoshi (url)Just another contact form plugin. Simple but flexible.  CSS Cache Buster 1.0» Alister Cameron // Blogologist (url)CSS Cache Buster does one very simple but very powerful [...]

  24. [...] Alternatively use this plugin [...]

  25. [...] 达人Matt给他提了个建议,让他使用filter来实现这个,这样,每个主题都会因为这个而受益。结果这个小老外就去写了一个插件,叫做CSS Cache Buster(点击链接,查看插件页面,下载插件)。 [...]

  26. [...] (I guess this would work with any other cached files e.g. JavaScript too). I ran across it here: http://www.alistercameron.com/2008/09/12/wordpress-plugin-css-cache-buster/ whilst in the world of [...]

  27. [...] WordPress does not have to load the data for each of them each time a post or comments are viewed. CSS Cache Buster is one good plugin for developers.  If you like to tinker with your CSS files, testing out new [...]

  28. [...] CSS Cache Buster SAVE [...]

  29. [...] So, if you are having the same problem as I had, you can use CSS Cache Buster plugin by Alister Cameron. Download CSS Cache Buster. [...]

  30. [...] I stumbled upon this module for WordPress, does drupal have a similar one: http://www.alistercameron.com/2008/09/12/wordpress-plugin-css-cache-buster/ [...]

  31. [...] to their current location. For details on how to use this plugin visit Breadcrumb NavXT.  CSS Cache Buster 1.0» Alister Cameron // Blogologist (url)CSS Cache Buster does one very simple but very powerful [...]

  32. [...] CSS Cache Buster – CSS Cache Buster is a simple but powerful plugin. It is a really great plugin for [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

Current ye@r *

    • splash.oiopublisher.com
    • marketsamurai.com
    • madmimi.com
    • www.medialayer.net
    • Advertise Here

  • My Posts in Your In-box!

    Enter your email address here for instant updates in your inbox, whenever I post something new.
    Your email address is in safe hands. Relax!
© Copyright 2008 Alister Cameron. All Rights Reserved Theme // Sitemap // RSS