Thursday, November 10, 2011

Forcing a Client Update of Cached Files

More than once now I've run into an issue where a stubborn browser will not pull a fresh copy of a file down from the server. This can especially be a pain when trying to debug some javascript or CSS. How can you test your changes if the damn client won't request the new code?

Here's a trick: append some junk parms to the end of the file source URL. So instead of

<script src="/Scripts/jquery.form.js" type="text/javascript"></script>

try

<script src="/Scripts/jquery.form.js?12345" type="text/javascript"></script>

As long as your app isn't processing parms on that URL (or at least not parm you added), you should force the client to download the new version.

For something more robust, try appending the current datetime before serving the file. For example, in ASP.NET,

<script src="/Scripts/jquery.form.js?<%:DateTime.Now.ToString("yyyyMMddhhmmss")%>" type="text/javascript"></script>

Friday, November 4, 2011

Going Wallet-less

Simplify.
Made in America.
From recycled plastic even.

Thursday, November 3, 2011

Javascript Pretty Print in Chrome Dev Tools

This is one of several reasons why I develop my javascript in Google Chrome.