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

Set-Cookie header bypass caches #1029

Closed
RonanOFM opened this issue Jan 25, 2021 · 3 comments
Closed

Set-Cookie header bypass caches #1029

RonanOFM opened this issue Jan 25, 2021 · 3 comments
Labels

Comments

@RonanOFM
Copy link

RonanOFM commented Jan 25, 2021

With cookie-based authentication, the header Set-Cookie is in the response headers on every SSR pages.
Set-Cookie auth.strategy=laravelSanctum; Path=/

Even pages that don't need authentication.

Why is it a problem ?

Because this header Set-Cookie is special, it bypass all caches, like Nginx cache or Varnish cache (doc links below).
Consequences are higher response time and it's quite bad for SEO.

Is it possible to add a config option for disable header Set-Cookie on SSR pages only ?

Docs :
Nginx : https://www.nginx.com/blog/nginx-caching-guide/
Varnish : https://varnish-cache.org/docs/3.0/tutorial/cookies.html

And thanks for this module 👍

@bmulholland
Copy link
Contributor

Deciding whether cookies allow a cache bypass is the responsibility of your cache configuration, not, say, the auth module. You should be able to set it up there.

@fogine
Copy link

fogine commented Dec 17, 2021

Deciding whether cookies allow a cache bypass is the responsibility of your cache configuration, not, say, the auth module. You should be able to set it up there.

Can we get back to this? While its the responsibility of the cache configuration to decide whether cookies allow a bypass cache. In this case, the issue seems like the auth module sets the following cookie for every response even if there is no user to authenticate. It should set auth strategy cookie once along the auth._token.local cookie value. Can you elaborate? @bmulholland Is there a specific reason why the auth.strategy cookie headers is set with every request response?

Set-Cookie: auth.strategy=local; Path=/

(I'm using local strategy).

@bmulholland
Copy link
Contributor

Feel free to log an issue for "cookie should not be set if the user isn't logged in" -- that's a separate issue from this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants