Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

assets-redirect

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assets-redirect

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Assets::Redirect

A Rack middleware for Rails with asset pipeline and asset digest enabled. This middleware is used to redirect any not found request to static asset to the latest version with digest in its filename by reading the manifest file generated after you run rake assets:precompile

For example, if a browser is requesting this URL, and the image with the digest has been removed:

http://example.org/assets/dog-faa42cf2fd5db7e7290baa07109bc82b.png

They will get redirected to the current version pointed by the manifest:

http://example.org/assets/application-faa42cf2fd5db7e7290baa07109bc99b.png

This gem is designed to run on your staging or production environment, where you already precompile all your assets, turn on your asset digest, and turn of asset compilation. This is useful if you're having a static page or email which refers to static assets in the asset pipeline, in this case the asset with the old digest can be lost after a deploymeny, and is convenient to automatically show the current version instead of a 404.

This gem has been inspired from https://github.com/sikachu/sprockets-redirect, but with the difference that in this gem both digested/undigested links will automatically redirect to the latest digested version.

Requirements

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add assets-redirect

Usage

This middleware will be enabled by default if you set config.assets.compile = false and config.assets.digest = true in your configuration file.

Running inside Docker with Sprockets

If you run the app in a Docker container and are using Sprockets is suggested to keep the Sprockets cache (tmp/cache/assets) in the container, this allows faster redirect lookups for .js and .css files.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/basecamp/assets-redirect.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 29 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc