Ensure that JavaScript files or CSS files are refreshed for each new version

ASP.Net, JavaScript/Ajax, PHP, Ruby/Rails, XHTML/CSS Add comments

I found a nice article explaining how to ensure that the newest version of your javascript or css is always loaded and not using old cached versions. The example shows how to accomplish this in ASP.Net but this technique can easily be applied to any server side code.

<script type=”text/JavaScript ” src=”FileName.js?v=<%=AssemblyVersionNumber()%>”>

The attribute does nothing other than trick the browser into thinking that the .js file must be retrieved from server for new version instead of cached .

Did You Enjoy This Post?

Be sure to grab my RSS feed so you don't miss out on more great articles.

This Post Was Brought To You By

How do I save time? I use FreshBooks for invoicing.

Get Information Technology magazine subscriptions and white papers for FREE!

Ensure that JavaScript files or CSS files are refreshed for each new version

2 Responses to “Ensure that JavaScript files or CSS files are refreshed for each new version”

  1. Err Says:

    Doesn’t work in Windows Safari.

  2. Err Says:

    Err… I take that back.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Login