Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

http-server settings cache pages too long #193

Closed
joewhite opened this issue May 22, 2014 · 1 comment
Closed

http-server settings cache pages too long #193

joewhite opened this issue May 22, 2014 · 1 comment

Comments

@joewhite
Copy link
Contributor

I tried to follow the guide to write a directive, but as soon as I switched from template to templateUrl, I found that I could edit my template .html file but the browser wouldn't reload my changes.

The problem turned out to be that, when I did npm start to start http-server, my template file was being sent back with a cache-control: max-age=3600 HTTP header, telling my browser to cache the file, and not even check again, for an hour. When I hit Reload, the browser would reload the top-level page despite this header, and it would reload the templates for my routes, but neither Chrome nor Firefox would reload the templates for my directives -- for those templates, they took the cache-control header very seriously.

The http-server docs mention that there's a parameter to configure the cache-control header, and it fixed the problem. The fix is to change this line in package.json:

"start": "http-server -a localhost -p 8000",

to:

"start": "http-server -a localhost -p 8000 -c-1",
joewhite added a commit to joewhite/lpc-chargen that referenced this issue May 23, 2014
Disable the local HTTP server's cache-control header, to fix the problem where the browser wouldn't reload templateUrl-based directive templates. Fixes angular#193.
@felixhao28
Copy link

An interesting finding: -c-1 does not work without -a localhost -p 8000.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants