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

Add appropriate cache headers to microservices, cache them in nginx #1936

Open
humphd opened this issue Mar 13, 2021 · 8 comments
Open

Add appropriate cache headers to microservices, cache them in nginx #1936

humphd opened this issue Mar 13, 2021 · 8 comments
Assignees
Labels
area: microservices area: performance Issues related to our performance type: enhancement New feature or request

Comments

@humphd
Copy link
Contributor

humphd commented Mar 13, 2021

In production we have our services running behind nginx, and it's amazing at caching. If we set the appropriate cache headers (e.g., cache-control, etag, etc), nginx and the users' browsers will improve performance by caching everything.

Some resources:

We can either do this manually in each service, or we could add some helper middleware in Satellite to allow each microservice to opt-in to various types of caching.

You can see how we do the caching for various things in nginx now: https://github.com/Seneca-CDOT/telescope/blob/master/config/nginx.conf.template#L173-L230.

See also https://github.com/Seneca-CDOT/telescope/blob/master/config/nginx.conf.template#L127-L133 and https://github.com/Seneca-CDOT/telescope/blob/master/config/nginx.conf.template#L233-L244 for how we do the nginx caching for the Telescope 1.0 backend. We'd need something similar for the API server definition https://github.com/Seneca-CDOT/telescope/blob/master/config/nginx.conf.template#L152-L164.

@humphd
Copy link
Contributor Author

humphd commented Mar 18, 2021

#1978 adds cache headers for the status service.

@Metropass
Copy link
Contributor

I might just make a module in Satellite that will add headers onto the passed Response object, I'll add in a test specifically for Cache-Control

@Metropass Metropass self-assigned this Mar 19, 2021
@humphd
Copy link
Contributor Author

humphd commented Mar 19, 2021

@Metropass there are npm modules that will do this, we could research one and use it.

@Metropass
Copy link
Contributor

I found this, it might be useful specifically for Cache-Control, I'm currently researching a module that will work for any type of CORS headers.

https://www.npmjs.com/package/http-cache-semantics

@humphd
Copy link
Contributor Author

humphd commented Mar 21, 2021

I don't think that module will help us here. I'm also not 100% sure we need to do anything special in Satellite for this: we just need to specify headers on a per-route basis in each microservice.

If we later find out that there are common patterns, we can extract them into something generic in Satellite; but let's not start there.

@aserputov aserputov added this to the 2.8 Release milestone Feb 23, 2022
@aserputov aserputov modified the milestones: 2.8 Release, 2.9 Release Mar 7, 2022
@JerryHue
Copy link
Contributor

@aserputov, what is your progress related to this?

@aserputov
Copy link
Contributor

@JerryHue work in progress.

@aserputov
Copy link
Contributor

aserputov commented Mar 22, 2022

@JerryHue I think we should move this one too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: microservices area: performance Issues related to our performance type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants