Replies: 1 comment
-
The feature idea seems interesting. Here are my observations:
As I said, if this works fine, then why not think about using a similar approach for setting up dynamic headers. -- I would suggest creating a feature issue defining clearly what this feature should do, then starting a simple prototype and picking up one of the checksum types first (e.g., MD5) to see how it will behave. Then, if that works as expected, decide to add the other checksum hashes gradually. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using SWS to serve a lot of small files. An external requirement is that each file is served with a header depicting its checksum like
X-Checksum-Sha256
,X-Checksum-Sha1
,X-Checksum-Md5
orContent-MD5
(i provide all of them even only one is ever consumed). My current solution is to re-render the config file anytime a file is added/changed and restart SWS.This has 2 downsides:
Apache supports calculating the checksum on the fly, altough they warn that this might cause performance issues as the value is calculated for each request and is not cached. #173 discusses a similar requirement for the
ETag
header which also touches on the topic of performance.One potential solution i would like to seen in SWS, is to serve the checksum header(s) by reading their precomputed value from a file; e.g. a sibling file with a file extension depicting the resulting header. Example:
A request for
/foo/bar.txt
would yield a response with 3 additional headersThe files itself are nothing special and can still be accessed normally (i.e. a request for
/foo/bar.txt.etag
would simply yield the content of the file as response and if a file/docroot/foo/bar.txt.etag.sha1sum
exists the response would contain its value in the X-Checksum-Sha1 header).How those files are generated and if their content are actually proper checksums is not the concern of SWS. what remains to be decided is if SWS does are least some form of validation (e.g. what happens if
/docroot/foo/bar.txt.md5sum
is a binary, large, or multiline file?)This feature should be disabled by default and configurable to only serve required headers regardless of which sibling files are present
Those are my requirements but this feature can even be taken a step further by adding support for serving arbitrary headers from sibling files
(e.g. read a TOML file as map and use it as header input)
I am not a Rust developer but from looking at the code, a potential solution would be to extend the FileMetaData struct to include the retrieved values
Beta Was this translation helpful? Give feedback.
All reactions