Add CACHE_CONTROL env, deprecate CACHE_MAX_AGE
Hey there
As discussed I would like to deprecate the CACHE_MAX_AGE option in favour of CACHE_CONTROL.
Users would then be able to set any CACHE_CONTROL directive they might need like stale-while-revalidate or s-maxage.
The change to add this feature would be rather small, however I had too much time on a train ride and improved a few things for readability.
Changes:
- give variables meaningful names (avoid
o,p,a,eetc.) - restructure the file so one can read it from top to bottom (env first, globals, handler entrypoint, data source implementation)
- add types for environment variables in node.js
- remove type casts (type narrowing with
if) - use
functionkeyword for all top level functions (instead of mixingconst fn = () => {}andfunction fn() {})
I know that my changes have gone a little far for this feature 😅, but I think this would also help future contributors (I'm open to split the PR in feature and code readability).
Thank you
@MarkusWendorf can you split this into the feature for CACHE_CONTROL PR and then the refactoring after that? That will let me merge the feature and update the docs, etc sooner. Thanks
Closed in favor of https://github.com/protomaps/PMTiles/pull/423