0

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.

Vick
  • 287
  • 2
  • 8
  • 1
    are you changint `v` parameter after compiling create.js? also have you tried to modify headers send by your http server with expires date – R A Jan 29 '15 at 12:14
  • Yep, chaged v parameter- nothing. Havn't tried headers yet - thanks. – Vick Jan 29 '15 at 12:24

1 Answers1

1

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]

Community
  • 1
  • 1
R A
  • 827
  • 13
  • 25
  • Thanks man, I have tried this, and it works. But the point is that my create.js file is already up-to-date. Meanwhile page behavior somehow is using older version of my create.coffee. – Vick Jan 29 '15 at 13:03
  • have you experienced same in other browsers that your default? looks like browser related bug – R A Jan 29 '15 at 13:26
  • Figured out it was a code error caused that odd behavior. Silly me. – Vick Jan 29 '15 at 13:37