Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:54:36+00:00 2026-05-28T07:54:36+00:00

I have a Rails app that uses Cloudfront as its CDN and sprockets to

  • 0

I have a Rails app that uses Cloudfront as its CDN and sprockets to compress assets and set long Cache-Control headers.

First request to an assets gives me response headers like so:

Cache-Control:public, max-age=31536000
Connection:close
Content-Encoding:gzip
Content-Type:application/javascript
Etag:"892a3afb514e3c84646835f9ef101026"
Last-Modified:Tue, 17 Jan 2012 16:05:17 GMT
Server:thin 1.2.11 codename Bat-Shit Crazy
Vary:Accept-Encoding
Via:1.0 c662f4e5a3bc7b224ce1bbecb0a23d82.cloudfront.net:11180 (CloudFront), 1.0 fc4797024fafe16fcc03e892c23f078d.cloudfront.net:11180 (CloudFront)
X-Amz-Cf-Id:bd2a89fb81bba2513f30d6940347693ef483defb4783da06d81b002af23545c39b9176b2c7cb144f,VF69FYlYU8ezzHQp7QkU2GvEQ8NmDqEwRX-wu7H63yNqE1ZlTaAq3g==
X-Cache:Miss from cloudfront
X-Runtime:0.012413
X-Ua-Compatible:IE=Edge,chrome=1

Perfect. It missed the cache from Cloudfront, fetched it from my app, so it should load it from there now from now on.

Now… if I refresh the page I get these response headers:

Connection:keep-alive
Server:thin 1.2.11 codename Bat-Shit Crazy
Via:1.0 86123d99569c9296c8605243e9a10621.cloudfront.net:11180 (CloudFront), 1.0 de9fc23d505dae3d19973a98bfa1eba0.cloudfront.net:11180 (CloudFront)
X-Amz-Cf-Id:a7bf6ffb30c43d306835190d210aeb8ec794c1ff619ad7aaecbad220c1822fe165bda624ae8382e1,bcij_88KOAvLPSqEKDRSvOBjEj7atiKBCAjSbqc2cfdb-BHOTi--LA==
X-Cache:RefreshHit from cloudfront
X-Runtime:0.006909
X-Ua-Compatible:IE=Edge,chrome=1

Looks like it hit Cloudfront. I get a 304 not modified. So it would seem that I’m not downloading the file again HOWEVER, I see this request also being made to my source server.

Why does this happen? Shouldn’t Cloudfront always cache my assets now? I’m versioning my assets, so I really NEVER want this to be fetched from the server save for the first request. Is there any way I can force this type of behaviour?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:54:36+00:00Added an answer on May 28, 2026 at 7:54 am

    Turns out Cloudfront won’t respect the Cache-Control header if no Date header is set.

    Adding in a date header to the assets fixed everything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app that uses heavily js (over 1MB total). I'd like
I have a Rails app that uses STI to handle different types of Users,
I have a rails app that uses partials and in development everything works great
I have a rails app that uses Sunspot and Solr for search functionality. I'm
I have a working rails app that uses imagemagick commands on my local mac
I have a Rails 3.1 app that uses the codebrew/backbone-rails . In a .jst.ejs
In a rails 3.0 app that uses jquery mobile for mobile devices I have
I have a rails app that uses Devise for user auth. In localhost:3000 my
I have a standard Rails app that uses a database, sqlite3 and the webrick
I have a rails app that uses a twitter library to pull in tweets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.