in reply to cache js code, but detect when it's changed?

I think the traditional way is to encode the version in the URL:

<script type="text/javascript" src="/js/foo/2.37/foo.js"></script>

That way, when you need a new version, you automatically get it. You should make all older version URLs redirect to the newest version.

Replies are listed 'Best First'.
Re^2: cache js code, but detect when it's changed?
by bcrowell2 (Friar) on Oct 06, 2007 at 20:22 UTC
    That's sensible -- thanks.

    I'd kind of like to avoid the need to rename files a lot, but this would certainly work. It just seems as though it ought to be possible to do something ajaxy that would get around this. E.g., the js script could detect that it was out of date, and then download the new code. But I guess no matter what, I still have to remember to change the version number in at least two places.

A reply falls below the community's threshold of quality. You may see it by logging in.