Comments (10)
+1 on this. Multiple -c
args should be supported. I would be ok with just not setting cache for .html
files but since the implementation is very simple we could probably aim to have something like:
$ http-server -c31536000:**/*.css -c-1:**/*.html
?
from http-server.
I would be ok PRing to this if a PR is welcome.
from http-server.
I'm not sure this is possible in the scope of http-server
.
First of all, "http-server is a simple […] command-line http server". I think it's sad that JS projects on GitHub trying to keep things simple (and leave advanced use cases to others) are constantly made more complex. But that's just MHO.
Second, http-server
is just a layer on top of ecstatic, which seems to allow only one caching duration.
from http-server.
Second, http-server is just a layer on top of ecstatic, which seems to allow only one caching duration.
@derhuerst the issue on ecstatic is right here in this thread, with a merged PR to add support to custom caching.
First of all, "http-server is a simple […] command-line http server". I think it's sad that JS projects on GitHub trying to keep things simple (and leave advanced use cases to others) are constantly made more complex. But that's just MHO.
It still seems reasonable to me that a static assets server has advanced support for caching. Adding this has not impact on who's not gonna have a use for multiple caching values.
Also, what do you think is going to happen if this doesn't land? People are going to use ecstatic
or connect
and roll out their own server.
from http-server.
Second, http-server is just a layer on top of ecstatic, which seems to allow only one caching duration.
@derhuerst the issue on ecstatic is right here in this thread, with a merged PR to add support to custom caching.
Sorry, didn't see this.
It still seems reasonable to me that a static assets server has advanced support for caching. Adding this has not impact on who's not gonna have a use for multiple caching values.
Also, what do you think is going to happen if this doesn't land? People are going to use ecstatic or connect and roll out their own server.
I've been following the http-server
's issues for quite a while and noticed a situation similar to many other FOSS projects: In the beginning, the software is small and simple. It has a narrow & shallow dependency graph. It does one thing and does it well. 😁
After a while, more and more tiny features get added, which all support a completely valid and reasonable use case. The software gets bigger and bigger, harder to maintain, etc. In the end, the tool will end up like curl
, rsync
or httpie
, which all do a dozen of things very well. One has to google for the correct usage or best patterns, another StackOverflow tag emerges because of the number of questions regarding the usage. 😄
This is all not really a problem, for a lot of feature requests however, it just seems like http-server
is – as it is described in the readme – not suitable for this kind of pluggable features.
To move on from general panicking, I see two specific features being requested quite often.
A web server with CLI-pluggable modules is needed. Something like express, ecstatic or koa, but configurable from the command line. Different features could be used more easily than setting up a JS file, just by passing flags. One would get the benefits of the CLI (aliasing, autocompletion, familiar syntax) "for free". Requested features that go in this direction: #35, #63, #83, #110, #139, #201, #67.
Second, a comfortable way to serve single page applications. This might become a possible duplicate of spa-server, spaserve and devserve. Issues regarding this: #69 and #95, #7, #80, #254.
Please keep in mind this is just my opinion and I'm not sure in what direction @indexzero wants to go with this project.
from http-server.
@derhuerst thanks for taking the time to write back.
I disagree. A A web server with CLI-pluggable modules
is a bad idea. At that point I might require htt-server
as a library and handle the CLI myself. I still believe adding strong cache support is in the scope of a popular static assets server like this project. Let's hope this lands or I will end up rolling out another yet module for the wrong reasons.
Everything you said seems unrelated. Let's see what happens and leaver the politics out of it.
from http-server.
A "web server with CLI-pluggable modules" is a bad idea.
That is my personal opinion as well, just like I believe in small CLI projects (like what http-server
has been like). But apparently (see the referenced issues) many people want a CLI HTTP server with a lot of features.
I still believe adding strong cache support is in the scope of a popular static assets server like this project.
I agree to this as it is phrased right now. But I also think that a detailed cache control should not be part of a small-scope module like this.
Everything you said seems unrelated.
It seems unrelated as it is a lot more general, because I tried to sum up what my impression of the feature requests of http-server
is.
from http-server.
Created a pull request for this #404
from http-server.
So, I am inclined to agree with @derhuerst and say this is not really in scope of http-server
since it feels like creeping. However, ecstatic
does now accept a function to be passed, and as a wrapper around ecstatic
, it entirely makes sense to pass this through as in #404.
from http-server.
After mulling this over for... oh my, a year and a half... I'm not so sure this should be added. I had agreed on passing the functionality through, but since that comment, ecstatic has been deprecated and we're set to to remove the dependency in #693, and we'll be removing excess functionality in #697.
from http-server.
Related Issues (20)
- Static File Directory flag HOT 1
- 404 error on the page with param HOT 2
- index.html change but doesn't have any auto refreshing must to manual refresh HOT 4
- Proxy target request header not present HOT 1
- Bug Report HOT 1
- Do not open a new browser window if one is already open HOT 1
- RangeError: Invalid time value HOT 3
- --cors usage is incorrect in the documentation HOT 1
- How to let the json file (*.json) return response header: 'application/json', instead of 'application/json; charset=UTF-8' HOT 1
- OWASP vulnerability in dependency tree HOT 1
- i use it with termux,but i do not know how to upload file to termux HOT 1
- http-server runing on project root folder path without any reasons HOT 2
- {"message":"You are not authorized"} in GitHub Codespace HOT 2
- Support relative path prefixes (base in vite.config.js) HOT 2
- Need a maintainer? HOT 9
- Link not opening in Browser
- Add bandwidth limit parameter HOT 1
- Option -c is not working
- gz not served HOT 1
- qr code generator in termal HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-server.