Vick
Vick

Reputation: 287

Coffee script and browser cache

I'm using node.js and gulp to compile coffee. Compiled js file is linked to html like this:

<script type="text/javascript" src="/assets/scripts/local/restore/create.js?v=150129_666"></script>

EDIT: create.js is up-to-date. But the page behavior and browser debbuger show I'm using some older version of my create.coffee. Can't get why, and how to get rid off. Or at least use current version of create.coffee. Thanks.

Upvotes: 0

Views: 258

Answers (1)

X A
X A

Reputation: 837

I have researched this topic on SO and looks like browsers can cache files even with get parameters. the best solution in my opinion:
How to force browser to reload cached CSS/JS files?

solution from the link:
modify js name (add current time for example) when generating your html

<script type="text/javascript" src="/assets/scripts/local/restore/create.1221534296.js"></script>

and using rewrite rule request appropriate file

RewriteEngine on RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]

Upvotes: 1

Related Questions