FOUR-20933: Implement ETag Caching for Screens Data#7771
Merged
eiresendez merged 6 commits intoepic/FOUR-20929from Dec 2, 2024
Merged
FOUR-20933: Implement ETag Caching for Screens Data#7771eiresendez merged 6 commits intoepic/FOUR-20929from
eiresendez merged 6 commits intoepic/FOUR-20929from
Conversation
- Introduced IfNoneMatch middleware to handle ETag-based caching: - Supports safe HTTP methods (GET, HEAD). - Returns "304 Not Modified" for matching ETags. - Handles multiple ETags and restores original request methods. - Added EtagManager for flexible ETag generation: - Default ETag generation uses MD5 hash. - Supports custom hash algorithms like SHA-256 via callbacks. - Included test cases: - Validate default ETag generation. - Test custom callback logic for ETag creation. This commit adds foundational support for ETag-based caching in the application.
…ware - Merged `etag.set` and `etag.if-none-match` middlewares into a single `etag.handle` middleware. - Simplified logic to reduce redundancy and improve maintainability. - Ensured ETag validation (`If-None-Match`) and generation are handled in the same flow. - Preserved compatibility with HEAD requests for consistency. This refactor improves clarity, reduces potential misconfigurations, and keeps the ETag logic centralized.
…d tests - Created tests for the new `HandleEtag` middleware: - Validates ETag generation and correctness. - Tests responses for both matching and non-matching `If-None-Match` headers. - Ensures proper handling of weak ETags (`W/`). - Removed old tests for `SetEtag` and `IfNoneMatch` middlewares as they are no longer needed. This commit improves test clarity and ensures the new ETag middleware behaves as expected.
- Added a test to validate ETag generation for user-specific routes using `etag:user`. - Simulates an authenticated user and verifies the ETag includes the user ID. These tests ensure the ETag middleware behaves correctly for both user-specific and common routes.
estebangallego
approved these changes
Nov 29, 2024
Contributor
estebangallego
left a comment
There was a problem hiding this comment.
Works as expected!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces foundational support for ETag-based caching in the application. The implementation includes a middleware to handle HTTP conditional requests and an extensible manager to generate ETags based on different strategies.
Solution
How to Test
Endpoints:
Screen Responses in Core:
GET https://processmaker.test/api/1.1/tasks/{param_1}/screen?include=screen,nested&screen_version={param_2}Screen Responses in Web Entry:
GET https://processmaker.test/api/1.0/webentry/{param_1}/{param_2}/screens/{param_3}?include=nestedRelated Tickets & Packages
Code Review Checklist