• Home
  • About Mitch
  • Speaking
  • Articles
  • Contact
  • Home
  • About Mitch
  • Speaking
  • Articles
  • Contact

Digital Strategist

WordPress Developer

Content Creator

Unapologetic Punk

Mitch Canter

  • X
  • Bluesky
  • GitHub
  • Twitch
  • YouTube
  • LinkedIn
Tutorial

Tired of Refreshing Your CSS Everytime You Make A Change?

CMDR Mitchcraft

Reading time: 1 minute

So am I.  I  make changes a lot live on the server (using the Web Dev Toolbar), and I have to hard-refresh every time I make a change.  Doesn’t sound like a big deal, but it cuts down on valuable time that could be done… well, not refreshing a page.  There is a way; versioning your CSS file.  The upside: it makes changes go live automatically without having to clear the cache.  The downside: it’s difficult to do, because the correct way to do it is by adding v=XXX manually every time you make changes.

Unless… you can find a way to do it automatically.  And Mark Jaquith has done just that.

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

So what does the ‘filemtime’ function do?  From the PHP website:

This function returns the time when the data blocks of a file were being written to, that is, the time when the content of the file was changed.

So everytime you change the file, the new change time gets parsed in using PHP and you’re able to have a new version every time.

Thanks to Mark for this great (and really clever) tip!

css, PHP
  • WordPress 3.3’s roadmap has been set… at least, it will be.

    WordPress 3.3’s roadmap has been set… at least, it will be.

    Reading time: 3 minutes

    Here’s the email I received of some of the proposed changes to WordPress – a lot of them look super exciting (goodbye IE7!) and plenty of them are just amazing.  What’s your favorite? User Feature: Media Uploader (azaozz) · Definitely v1: Integrate Plupload into dashboard. (GSoC project) · Probably v2: Improve our image manipulation and…

    WordPress
  • 5 Essential WooCommerce Extensions, Add-Ons & Plugins

    5 Essential WooCommerce Extensions, Add-Ons & Plugins

    Reading time: 2 minutes

    WooCommerce is one of the most powerful WordPress eCommerce solutions on the market. Out of the box, it does everything you’d expect an eCommerce system to do: Host products Have a scannable product listing Take orders for products Accept payments through PayPal Allow people to use coupons But, sometimes, you need to think outside of…

    WordPress