You are not logged in.
Pages: 1
I hate it when I push a new version of an old site and a site visitor’s browser hangs on to the old CSS like a crazed harpie. Here’s something that forces new css weekly. It can easily be adapted to any interval you like by changing the format of the date call.
<txp:variable name="css-date">?<txp:php>echo date('W-y');</txp:php></txp:variable>
<link rel="stylesheet" type="text/css" media="screen" href="<txp:rvm_css format="url"/><txp:custom_field name="css-date"/>" />
<!-- Fix for the Redmond Ass Hats -->
<!--[if IE 6]><link rel="stylesheet" type="text/css" media="screen" href="<txp:rvm_css name="IE6" format="url"/><txp:variable name="css-date"/>" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<txp:rvm_css name="IE7" format="url"/><txp:variable name="css-date"/>" /><![endif]-->
<!--[if IE 8]><link rel="stylesheet" type="text/css" media="screen" href="<txp:rvm_css name="IE8" format="url"/><txp:variable name="css-date"/>" /><![endif]-->
This is for rvm_css just replace with <txp:css /> tag if you want to go native.
{EDIT} DUH. er. sorry guys, that was supposed to be variable not custom_field thanks gocom.
Last edited by mrdale (2012-04-04 17:44:05)
Offline
That snippet does not work. Custom_fields are used to display article data. They can’t be directly populated and do not have container mode. That custom_field should be variable.
Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />
Offline
Really what you want is the date to update when you upload a new css file, except I can’t think of a good way off-hand as txp’s css table doesn’t have a datestamp. Two not-really-idea-but-probably-possible ideas:
css-date variable (or css-version-number) in adi_variable and then update it manually when you update the css. Of course that requires two manual steps./files folder. You can then append the file’s modified date after the ? mark. It’s not so nice organisation-wise but would auto-update the date when you update the css.Maybe someone else has a better idea.
TXP Builders – finely-crafted code, design and txp
Offline
jakob wrote:
I can’t think of a good way off-hand as txp’s css table doesn’t have a datestamp.
No, but if you’re using rvm_css that puts the CSS in the filesystem, which thus has a last modified time. Shouldn’t be tricky to leverage that and stuff it on the end of the link… it’d be less intensive on mrdale’s server than doing it every request and at least gives the browser some cache advantages, and puts you in control.
Last edited by Bloke (2012-04-04 19:41:10)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern.
Txp Builders – finely-crafted code, design and Txp
Offline
Another option is a tiny plugin on the CSS save step which stuffs the current datestamp and CSS file name in the prefs table. Piece of cake to read that back at display time.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern.
Txp Builders – finely-crafted code, design and Txp
Offline
but if you’re using rvm_css that puts the CSS in the filesystem
Ah, I didn’t know that. Then you could go off and get the file’s last-modified date and output that after the ?-mark…
… and puts you in control
and gets the client’s browser to grab a new version of the file when you update it, rather than when the next weekly interval comes around.
TXP Builders – finely-crafted code, design and txp
Offline
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Pages: 1