http-server icon indicating copy to clipboard operation
http-server copied to clipboard

Feature: Do not cache local, but cache remote files (option)

Open adiba opened this issue 6 years ago • 9 comments

Currently, when the cache time is passed via the -c option, it is applies to both local files and files transferred via the --proxy option. However, disabling caching by using -c-1 or -c 0 for remote addresses can make page loads quite slow. So ideally the --proxy option would also take an optional timeout argument.

adiba avatar Jul 08 '17 17:07 adiba

Could you provide more context/description? What would you like to see in this option, and where exactly would caching happen and not happen? What do you mean by local and remote files?

thornjad avatar Dec 18 '19 15:12 thornjad

Can't talk about remote files, but as far as local files are concerned, the server still caches the loaded CSS stylesheet and doesn't update on refresh, even with the -c-1 flag.

matronator avatar Sep 13 '21 16:09 matronator

By local do you mean files on the server or client?

thornjad avatar Sep 13 '21 18:09 thornjad

Sorry, don't understand how you mean that. By local I meant the files that are locally on my disk in the root directory, so for example it would be the css/index.css file for the stylesheets.

matronator avatar Sep 13 '21 19:09 matronator

The clarification is because those files are only local to http-server, not to the browser (the client). That doesn't sound quite right though because the server doesn't do any caching at all, are you sure it's not being cached in the browser?

With -c-1, the server can only tell the browser not to cache, it can't actually make it happen, which means sometimes the browser caches anyway.

thornjad avatar Sep 13 '21 19:09 thornjad

Oh, yeah sorry, you're right. Manually force reloading with the cache updates the site, so it must be the browser caching it.

matronator avatar Sep 13 '21 20:09 matronator

I think I meant: local files are the ones local to the http-server, remote files are the ones accessed via the --proxy option. So ideally the --proxy option would also take an optional timeout or so?

Sorry for such late clarification.

adiba avatar Sep 13 '21 23:09 adiba

Oh, yeah sorry, you're right. Manually force reloading with the cache updates the site, so it must be the browser caching it.

https://github.com/http-party/http-server/issues/412 https://stackoverflow.com/questions/47470325/what-is-the-difference-between-max-age-0-and-max-age-1-in-cache-control

adiba avatar Sep 14 '21 08:09 adiba

This issue has been inactive for 180 days

github-actions[bot] avatar Mar 23 '22 12:03 github-actions[bot]