0

This is the second time today, I ran into this problem: occasionally after I modified the template file (.html), the old template is still used. I tried multiple ways to solve this:

  1. refresh the page in browser;
  2. refresh the page in browser with ctrl+f5;
  3. even restarting Apache.

But the result seemed really inconsistent, and some time none of the above worked. I suspect this somehow relates to how the transpile is triggered.

How can I grantee that the transpile is triggered when the template is modified?

(Not sure whether the code matters in this case, but you can reference this question I asked earlier, the fixed version of that code was used. For exmple, if I change the placeholder to below, the mis-spelled "first" won't necessarily show up.)

placeholder="Enter firsttttta name here">

Update:

As @basarat pointed out in his comment, this was solved by adding the following to httpd.conf (I added ts|ts!transpiled to the list. ts is the file extension for typescript, and angular2 seemed to use ts!transpiled for transpiled script.)

<filesMatch "\.(html|htm|js|css|ts|ts!transpiled)$">
  FileETag None
  <ifModule mod_headers.c>
     Header unset ETag
     Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
     Header set Pragma "no-cache"
     Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
  </ifModule>
</filesMatch>
Community
  • 1
  • 1
Peter Pei Guo
  • 7,536
  • 17
  • 32
  • 51

1 Answers1

1

refresh the page in browser with ctrl+f5;

The ideal solution is to send headers during development from the server to tell the client to not to cache the result:

Cache-Control:no-cache, no-store, must-revalidate
Pragma:no-cache
Expires:0
basarat
  • 207,493
  • 46
  • 386
  • 462
  • No. Since you are using apache you can put this in your .htaccess : http://stackoverflow.com/a/11724596/390330 – basarat Dec 24 '15 at 04:34
  • This should help with your TypeScript JS code compile too ;) – basarat Dec 24 '15 at 04:38
  • Yes, now it is worry free. – Peter Pei Guo Dec 24 '15 at 04:39
  • I am updating my OP, to include "ts|ts!transplied". ts is the file extension for typescript, and angular2 seemed to use "ts!transplied" as the extension for transplied typescript. I think that way, it is more complete in this situation. – Peter Pei Guo Dec 24 '15 at 04:45