Yii 1.1: csclientscript

Component that appends version to every JS/CSS link
13 followers

When you are using "expires" headers with long in the future times, there can be problem with deploying changes, as some users can still be using cached CSS and JS files. You can change the name of such files every time, but this breaks code versioning.

Another solution provided by this extension is to append version (any string identifying version) as GET parametr to resources links, like:

<link rel="stylesheet" type="text/css" href="/css/site.css?v=1.0.1" />

then, after any change, you just increment version, and every browser will treat such link as new one and fetch file content.

Requirements

There are no special requirements. It was tested with Yii 1.1.7 and 1.1.8.

Usage

Just expand Zip in your components directory (or any other) and append configuration:

'components'=>array(
  ...
  'clientScript' => array(
    'class'=>'CSClientScript',
    'version'=>'1.0.3'
  ),
  ...

Total 3 comments

#6489 report it
redguy at 2012/01/13 10:46am
...

started using EClientScript and I think my extension will be abandoned. EClientScript provides same caching prevention on content change and also merging multiple js/css files into one... YSlow gives A+ ;)

#4536 report it
Veseliq at 2011/07/18 09:00am
Great Idea!

Man, I've run into this problem so many times. Thank you!

#4425 report it
Junior - df9 at 2011/07/07 06:22am
Great!

haven't tested yet, but it is something i'll use for sure in a near future!

regards!

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: redguy
  • Category: Caching
  • Votes: +8
  • Downloaded: 397 times
  • Created on: Jul 7, 2011
  • Last updated: Jul 7, 2011