Vampire Trix

Twitter

Quick-tip: how to avoid getting your stylesheet cached

Ever since I’ve started using openDNS my stylesheets constantly get cached which makes it really hard to develop – so here’s a little trick on how to avoid getting your stylesheets cached. It’s very simple.

Instead of doing this:

<link href="style.css" rel="stylesheet" />

We’ll use this:

<link href="style.css?<?php echo time(); ?>" rel="stylesheet" />

This bit of code, echo time(); will display the time which is different all of the time, so it effectively avoids getting your style.css cached.

Kevin