4

I wish to serve images from a S3 bucket with Cloudfront as CDN frontend, for that I tried the following:

What I wish to acheive (Attempt 2) -- (Misses cloudfront cache randomly)

I have the following setup to serve images: ( Cloudfront --> Nginx --> S3 ) Cloudfront -> Nginx -> S3

<<<<<<<< Sample S3 headers >>>>>>>>>> Attempt-2 S3 headers

<<<<<<<< Sample Nginx -> S3 headers (Added Cache-Control) >>>>>>>>>> Attempt-2 Nginx->S3 headers

<<<<<<<< Sample Cloudfront -> Nginx -> S3 headers >>>>>>>>>> Attempt-2 Cloudfront->Nginx->S3 headers

What I am currently working with (Attempt 1) -- (Hits cloudfront as expected everytime)

Cloudfront -> S3

** Cloudfront Settings **:

What am I screwing up in Attemp-2 with my headers ? ( Cloudfront missing randomly )

Url(http://cdn.example.com/abc.jpg) & Url(http://cdn.example.com/abc.jpg?v=1) both will have same ETag, is that fine ?

Yugal Jindle
  • 161
  • 1
  • 6

1 Answers1

1

Maybe this is related to the clients making requests that indicate that cache should be by-passed?

E.g., maybe Pragma: no-cache appears in the requests, and is respected by the front-facing server, resulting in a miss?

cnst
  • 12,948
  • 7
  • 51
  • 75
  • Since my access method remains same every-time, this should not be the case. This would have resulted in constant `miss` – Yugal Jindle Jan 21 '14 at 23:06
  • What are your access methods? Do you use a browser? When you click various refresh and shift-refresh or whatever, they do send these extra no-cache headers. – cnst Jan 21 '14 at 23:10
  • I have tried all `browser`, `curl`, `wget`, etc. Though, I didn't checked the defaults. Shouldn't it miss everytime if its the case that you are talking about. – Yugal Jindle Jan 21 '14 at 23:33
  • Why would it miss all the time? You don't always have these extra no-cache headers flying around. Also, maybe there's some extra logic involved in cloudfront.net of when the no-cache directives are respected, and when not. If the above is not an answer, then, IMHO, the question is probably off-topic for serverfault. – cnst Jan 21 '14 at 23:40
  • Interesting, `extra logic` in cloudfront.net. Let me dig into that. – Yugal Jindle Jan 22 '14 at 09:51
  • Here are my request-headers with `curl`: `User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3`, `Host: example.com`, `Accept: */*` – Yugal Jindle Jan 22 '14 at 11:32
  • 1
    See this discussion for more : https://forums.aws.amazon.com/thread.jspa?threadID=144286&tstart=0# – Yugal Jindle Jan 24 '14 at 14:19
  • Cloud front is pull-only. Nginx may screw headers in case of using caching headers and gzipping (which is equal to modifying) the response. – Anatoly Mar 27 '15 at 13:40