Ad Space
Ad Space

Hosting Geared For
your CMSMS needs

CMSMS ready Hosting

Hosting Starting at $15

  • • Hosted Mail
  • • Personal Control Panel
  • • CMSMS 1.8.1 tested
  • • Lightly packed servers
  • • Intrusion Detection
  • • URL monitored
  • • Custom solutions available

Order your hosting Now

CP Blogs

Smarty way to file version for Yslow greatness

Posted by: Jeremy Bass
on Aug 25, 2009

Category:

Coding, Intermediate, Smarty, .htaccess, Apache server, Browsers - Compatibilities and Inconsistencies, HTML, CMS Made Simple

Summary: A Smarty way to version files so you can get an A in Yslow

Ad Space

Hello again,
So do you know about ySlow and the what’s and why it's a great tool? No? Well, then you need to read this first!! If you don't have this under your belt you'll need more time and this is not going to be helpful.

Ok, you've done your reading and have been getting A's on your sites, they load up quick and you're happy dappy... but it's a pain to change your js or css files. Find a mistake a few days later and you have to go back and not only change the file name but to go in to the templates or file and change the links to the new file... Wow what a pain..

Versioning Solution

Now the solution example is based in the CMSMS what’s what, but that doesn't mean you can't use this trick, just make the right changes.

Make a UDT named fileTime

$files=$params['File'];
$fileTimeIS=filemtime($files);
echo $files."?".$fileTimeIS;

Yeah the is it... and the link in your templates should be...


<script type="text/javascript" src="{fileTime File='lib/JS/MasterCore.js'}"></script>

What's the output then?

<script type="text/javascript" src="lib/JS/MasterCore.js?1272763127"></script>

It is that simple... Now every time you update "MasterCore.js" the end user gets the new file and all you had to do was upload it dispaite the same name.

I will make this into a mod for CMSMS that take a db or file entry and minify it and run this simple trick. But I need more support for that so donate up if you want it.

Hope this helps,

Cheers
JeremyBass

Ad Space

Get Social With It

[+]

Add A Comment

[+]

Code in the picture:
Title:
Your Name(*):
Email:
Notify me of any further comments to this thread:
Website:
Comment(*):
 
Previous page: Hosting FAQ Next page: Experimental