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

  • SEARCH
  • Home
  • 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 3616604
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:31:09+00:00 2026-05-18T22:31:09+00:00

Background I’m currently working on a Rails 3 project that I intend to use

  • 0

Background

I’m currently working on a Rails 3 project that I intend to use with Amazon CloudFront with a custom origin pointing back to my actual web server. This means that my web server will tell the browser to retrieve static assets from CloudFront, if CloudFront has the asset cached it will return it, if it does not it will retrieve it using the same path from my web server and then cache it for future requests.

Problem

Amazon CloudFront drops and ignores query string parameters when determining whether it should bust it’s own cache to re-download the asset from it’s origin. This obviously poses a problem with the way Rails generates URLs with the RAILS_ASSET_ID which is to do: /assets/path/to/asset.ext?RAILS_ASSET_ID. With the default asset URLs CloudFront will hold onto stale assets for up to 24 hours.

Solution?

What I’m hoping to do is somehow override the way Rails 3 generates asset tags so that I can generate URLs like /assets/RAILS_ASSET_ID/path/to/asset.ext. I already have a solution for how to make the web server respond to those URLs, I just need to figure out how to make Rails generate the URL.

Notes

  1. My RAILS_ASSET_ID will be a sub-string of my latest git commit hash. Setting this will be handled by capistrano during the deployment process. I am OK with busting all asset caches on each deployment, I don’t need asset-specific IDs
  2. I have already attempted to override ActionView::Helpers::AssetTagHelper.rewrite_asset_path but it didn’t seem to work and from what I read this is a private method that should not be relied upon.
  3. Thank you in advance!
  • 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-18T22:31:10+00:00Added an answer on May 18, 2026 at 10:31 pm

    “Set ActionController::Base.config.asset_path to a proc that takes the unmodified asset path and returns the path needed for your asset caching to work.”

    That’s from the AssetTagHelper documentation.

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

Sidebar

Related Questions

Background We currently use OpenID for authentication of users, and use the Claimed Identity
Background This is only my second PyQt4 project. Developing a Windows app that has
Background My project is urgent and requires that I iterate a large XML file
Background: I'm working on a homebrew project for managing a collection of my own
Background I have a dimension table that has a single record for each day.
Background, Part 1 I have a form that collects both frequency and duration from
background: I work on an asp.net web application that is on a company intranet.
Background: I'm writing a 'standard' (nothing special) web application in Ruby (not Rails) and
Background We need to develop a specialised CMS (internal use only) to support a
Background: I have a css and a js that is used only by the

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.