-
Notifications
You must be signed in to change notification settings - Fork 36
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
Support all HTTP Caching mechanisms #70
Comments
Following are suggested unimplemented improvements. Mandatory requirements from RFC9111 are marked with "must", others are just either suggested or optional. Ranked by importance. 1 Implicit cachingThe current code only caches response with a
And if any of the following applies, the response should not be in the cache:
https://www.rfc-editor.org/rfc/rfc9111.html#section-3 2 Vary headerBased on the fields in the The could lead to different implementations in the code. For example, we can remain the original code and only add a condition to check if the https://www.rfc-editor.org/rfc/rfc9111.html#section-4.1 3 Invalidating cache for unsafe request methodsBecause unsafe request methods such as PUT, POST, or DELETE have the potential for changing state on the origin server, intervening caches are required to invalidate stored responses to keep their contents up to date. A cache must invalidate the target URI when it receives a non-error status code in response to an unsafe request method (including methods whose safety is unknown). https://www.rfc-editor.org/rfc/rfc9111.html#section-4.4 4 Add validation for responseWhen a cached response is stale, it may use validation to check if it's still able to use. The current code already implemented the validation mechanism, but it only do validations for requests with Validation should also apply to response with the https://www.rfc-editor.org/rfc/rfc9111.html#section-4.3 5 Filtering the headerCurrent cache copies all the headers from the response. However, not all the header should be forwarded or cached:
https://www.rfc-editor.org/rfc/rfc9111.html#section-3.1 6 Unimplemented DirectivesCurrent code already implemented the following directives:
Following are unimplemented: request directives:
response directives (a cache must obey the Cache-Control directives defined here):
https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2 7 Partial content storing and combiningIf the response uses Range specifiers, the cache may store incomplete responses. When the response is complete, the cache may combine a new response with one or more stored responses. https://www.rfc-editor.org/rfc/rfc9111.html#section-3.3 https://www.rfc-editor.org/rfc/rfc9111.html#section-3.4 8 Heuristic freshnessIf the response has a https://www.rfc-editor.org/rfc/rfc9111.html#section-4.2.2 9 Prevent overflow for delta secondsIf a cache receives a delta-seconds value greater than the greatest integer it can represent, or if any of its subsequent calculations overflows, the cache must consider the value to be 2147483648 (2^31) or the greatest positive integer it can conveniently represent. |
Thank you @wzy1935 for this detailed reported, great work! It seems to me that the following items could be priorities for safety reasons:
What do you think? 8 Heuristic freshness seems like a low-hanging fruit, correct? |
Sure! And I can work on these that you mentioned. |
Verify caching handles all cases defined in https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
It seems the caching implementation takes into account resources when the backend responds with headers defined by the modern specs.
Some backends may use older caching headers.
The text was updated successfully, but these errors were encountered: