We have been having a problem with files being unexpectedly cached by the content-cache.
Most of our sites load CSS with URLs like https://ubuntu.com/static/css/styles.css?v=53216fc, where the v= parameters contains the start of an MD5 hex hash of the file's contents. There was nothing in the application that verified this hash, but the theory was that because you would only ever use a new hash when you wanted the latest file, these files would end up being cached at the correct hash URLs. For some reason, this didn't work out this way. We're not quite sure why.
Anyway, here I'm adding a check to FlaskBase to actually test the file's contents against the provided hash. If it doesn't match, it will return a 404. This should prevent the content-cache from caching erroneous files at URLs containing hashes. If the file contents doesn't match the requested hash, the 404 response should stop the file from being cached.
Fixes #47
I also did a drive-by fix of the flask 2.0 test issue:
We have been having a problem with files being unexpectedly cached by the content-cache.
Most of our sites load CSS with URLs like
https://ubuntu.com/static/css/styles.css?v=53216fc
, where thev=
parameters contains the start of an MD5 hex hash of the file's contents. There was nothing in the application that verified this hash, but the theory was that because you would only ever use a new hash when you wanted the latest file, these files would end up being cached at the correct hash URLs. For some reason, this didn't work out this way. We're not quite sure why.Anyway, here I'm adding a check to FlaskBase to actually test the file's contents against the provided hash. If it doesn't match, it will return a 404. This should prevent the content-cache from caching erroneous files at URLs containing hashes. If the file contents doesn't match the requested hash, the 404 response should stop the file from being cached.
Fixes #47
I also did a drive-by fix of the flask 2.0 test issue:
Fixes #48
QA
Go to https://ubuntu-com-10738.demos.haus/static/css/styles.css?v=53216fc - it works. Now go to https://ubuntu-com-10738.demos.haus/static/css/styles.css?v=53216fd - 404. Tada!
Also, see the tests pass