Skip to content
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

Implement a caching mechanism #1

Open
josealonso opened this issue Jan 30, 2023 · 1 comment
Open

Implement a caching mechanism #1

josealonso opened this issue Jan 30, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@josealonso
Copy link
Owner

The Etag, as well known as Entity Tag, is an HTTP header corresponding to the current status of a requested resource.
When an API receives a request, it will calculate a hash value. This value is the ETag.

Consumers can send the ETag value on the header If-None-Match. The API server will process the request and calculate the ETag again, comparing it with the value sent by the client. If it matches, the API server will response the status code 304 Not Modified. The client will then update the cache as it knows the response is still valid.

Credit goes to @ivan1405

@josealonso
Copy link
Owner Author

Configuring the Etag header is easy in Spring Boot:

@Bean
public ShallowEtagHeaderFilter shallowEtagHeaderFilter() {
    return new ShallowEtagHeaderFilter();
}

Explained here

@josealonso josealonso self-assigned this Jan 30, 2023
@josealonso josealonso added the enhancement New feature or request label Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant