-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add Cache Control Header #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
will this take in account : |
i propose a default max-age = 0, and then just leave it out if it is not set, i.e. current behaviour. So the change does not break existing sketches.
|
why ignoring max-age = 0 ?
|
How about , if i made it a int32_t then -1 = no-cache, 0 = max-age=0, >1 as expected? |
maybe add in -2 to just leave it out, and set default value to -2? |
start to be complex - also this does not take in account other command or cumulative command like : |
ah, i see. yes i like ur idea. would it be acceptable to use a nullptr as default ?
or is this frowned on? |
Just make sure you don't store cache_header as |
Yes my bad, should use String not const char * |
This was why I was originally thinking of using int32_t, as it is conceptually simpler for me, and doesn't eat more ram up. If you think this would be a good addition I will work on it later and submit a PR? |
While you are working on the static server, why not add the option to use gzipped content? I saw it was missing from the source but was working on other things and did not want to bother mixing merges. Gzipped files are much. much smaller and permit larger web apps to be stored on the flash. Not to mention the option to store some nice content even on a 512K board. |
I will take a look at that too. |
I've added a Gzipped handling. What would you guys prefer.. to serve a non-compressed over a compressed file, or vice versa. just thinking for debugging it might make it easier that it only serves a gz if it can't find an exact match? That way you can edit a non compressed file get it working, without having to delete an old gx version. I'm open either way. what do you think? Also you set everything up as a the content type you want to send. ie.. you point to an htm, js file in spiffs which sets the content type correctly, then put the .gz file in there and it finds it, and sets the content encoding to gzip. If you point the handle to a .gz file , you will download it. sound ok? |
This logic sounds fine to me. On Wed, Nov 11, 2015, 23:17 sticilface [email protected] wrote:
|
@sticilface |
The cache control header is added to any servestatic handlers. for example to serve your whole SPIFFS
The web server will send any file with a .gz, when the non-compressed is requested, setting the correct content-type and content-encoding headers. eg.. client request is for file abc.txt if there is an abc.txt.gz file then it will serve that. However, if there is an uncompressed file abc.txt it will serve that in preference to the compressed one. hope that helps |
@sticilface
|
looks good to me. |
great, thanks ;-) |
Regarding ESP8266WebServer:
When serving files from SPIFFS, have the option to add Cache Control Header. Having this option makes for example serving static javascript files much much better as the ESP does not have to continually serve up unchanged files.
proposed implementation
Any thoughts for or against such an addition? I'm willing to / attempt to implement it.
The text was updated successfully, but these errors were encountered: