我已經在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請求的響應?