LoginSignup
3
3

More than 5 years have passed since last update.

CloudFront (Pragmaの扱い)

Posted at

今回たまたま調べることになったCloudfrontでのPragmaの扱い。
まあ、CloudFront固有の扱いではないんだけど・・・。

CloudFront エッジキャッシュにオブジェクトを保持する時間の指定(有効期限切れ)

上記にはいろいろCacheされる場合の動作が書いてあるが、Pragmaの扱いが書いていない。
例えば、下記のような場合

$curl -I http://hogehoge.cloudfront.net
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Cache-Control: max-age=3600
Date: Tue, 16 Sep 2014 **:**:** GMT
Expires: Tue, 16 Sep 2014 **:**:** GMT
Pragma: no-cache
Set-Cookie: hogehogeID=************; path=/
X-Cached: Tue, 16 Sep 2014 **:**:** GMT
Vary: Accept-Encoding
X-Cache: Miss from cloudfront
Via: 1.1 ****************cloudfront.net (CloudFront)
X-Amz-Cf-Id: *************************

このような場合、2回目のアクセス以降も "Miss from cloudfront" となっている。
まあ、この表示を見ればもうわかるはず。

そのまえに今一度RFC2616を見てみよう。

RFC2616

抜粋

HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client had
sent "Cache-Control: no-cache". No new Pragma directives will be
defined in HTTP.

つまり、RFC2616 では "Pragma: no-cache" は "Cache-Control: no-cache"の場合と同様に処理すべきと書かれている。
CloudFrontでも"Pragma: no-cache" はこれに沿った扱いとなっているようだ。

そのため、テストしたケースではPragma header を取り除けばエッジ側で問題なくCacheされる。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3