我已经在Firebase之上构建了GraphQL API。该API使用连接到Firebase托管的云端功能来处理请求。缓存对Firebase功能POST请求的响应
我的目的是缓存发送给GraphQL API的请求的响应。
的ExpressJS中间件配置如下:
function setCacheHeaders(req, res, next) {
res.set('Cache-Control', 'public, max-age=300, s-maxage=600');
return next();
}
如果我发送一个GET请求到API,我看到它击中CDN:
X-Cache: HIT
X-Cache-Hits: 1
X-Served-By: cache-lhr6343-LHR
然而,当我发送POST请求(这是与GraphQL端点交互的常用方式,即使它是只读操作)我注意到没有请求正在访问缓存。但是,响应包含以下标头:
HTTP/1.1 200 OK
Accept-Ranges: bytes
Connection: keep-alive
Content-Length: 311
Content-Type: application/json
Date: Thu, 27 Jul 2017 05:41:02 GMT
Server: nginx
Strict-Transport-Security: max-age=31556926
Vary: Accept-Encoding, Authorization, Cookie
Via: 1.1 varnish
X-Cache: MISS
X-Cache-Hits: 0
X-Served-By: cache-lcy1133-LCY
X-Timer: S1501134062.745716,VS0,VE640
cache-control: public, max-age=300, s-maxage=600
function-execution-id: xg0qjlghrtrv
x-cloud-trace-context: 02434a5f73159e24d949e74026bb8843, 02434a5f73159e24d949e74026bb8843
x-powered-by: Express
是否无法使用Firebase托管缓存对POST请求的响应?