@@ -50,7 +50,16 @@ def __init__(self, hs: "HomeServer"):
5050
5151 async def on_GET (self , request : SynapseRequest ) -> tuple [int , JsonDict ]:
5252 # This endpoint is unauthenticated and the response only depends on
53- # the upstream OIDC provider metadata, so it can be cached.
53+ # the metadata we get from Matrix Authentication Service. Internally,
54+ # MasDelegatedAuth/MSC3861DelegatedAuth.issuer() are already caching the
55+ # response in memory anyway. Ideally we would follow any Cache-Control directive
56+ # given by MAS, but this is fine for now.
57+ #
58+ # - `public` means it can be cached both in the browser and in caching proxies
59+ # - `max-age` controls how long we cache on the browser side. 1h is sane enough
60+ # - `s-maxage` controls how long we cache on the proxy side. Since caching
61+ # proxies usually have a way to purge caches, it is fine to cache there for
62+ # longer (24h), and issue cache invalidations in case we need it
5463 request .setHeader (b"Cache-Control" , b"public, max-age=600, s-maxage=3600" )
5564
5665 if self ._config .mas .enabled :
@@ -99,7 +108,16 @@ def __init__(self, hs: "HomeServer"):
99108
100109 async def on_GET (self , request : SynapseRequest ) -> tuple [int , JsonDict ]:
101110 # This endpoint is unauthenticated and the response only depends on
102- # the upstream OIDC provider metadata, so it can be cached.
111+ # the metadata we get from Matrix Authentication Service. Internally,
112+ # MasDelegatedAuth/MSC3861DelegatedAuth.issuer() are already caching the
113+ # response in memory anyway. Ideally we would follow any Cache-Control directive
114+ # given by MAS, but this is fine for now.
115+ #
116+ # - `public` means it can be cached both in the browser and in caching proxies
117+ # - `max-age` controls how long we cache on the browser side. 1h is sane enough
118+ # - `s-maxage` controls how long we cache on the proxy side. Since caching
119+ # proxies usually have a way to purge caches, it is fine to cache there for
120+ # longer (24h), and issue cache invalidations in case we need it
103121 request .setHeader (b"Cache-Control" , b"public, max-age=3600, s-maxage=86400" )
104122
105123 if self ._config .mas .enabled :
0 commit comments