We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The assets controller as it currently works by streaming the file:
def show @asset = Maglev::Asset.find(resource_id) send_data @asset.download, filename: @asset.filename, type: @asset.content_type end
This results in cache-control: max-age=0, private, must-revalidate
cache-control: max-age=0, private, must-revalidate
The most sensible fix is to respect the config.public_file_server.headers set by in the Rails environment.
config.public_file_server.headers
I suggest something like below
def show @asset = Maglev::Asset.find(resource_id) send_data @asset.download, filename: @asset.filename, type: @asset.content_type cache_control = Rails.configuration.public_file_server.headers["cache-control"] if cache_control && cache_control.match(/max-age=(\d+)/) max_age = Regexp.last_match(1).to_i expires_in max_age.seconds, public: true end end
The text was updated successfully, but these errors were encountered:
For now I am using the following in app/overrides/controllers/maglev/assets_controller_override.rb
app/overrides/controllers/maglev/assets_controller_override.rb
Maglev::AssetsController.class_eval do def show @asset = Maglev::Asset.find(resource_id) send_data @asset.download, filename: @asset.filename, type: @asset.content_type, disposition: "inline" cache_control = Rails.configuration.public_file_server.headers["cache-control"] if cache_control && cache_control.match(/max-age=(\d+)/) max_age = Regexp.last_match(1).to_i expires_in max_age.seconds, public: true end end end
Sorry, something went wrong.
No branches or pull requests
The assets controller as it currently works by streaming the file:
This results in
cache-control: max-age=0, private, must-revalidate
The most sensible fix is to respect the
config.public_file_server.headers
set by in the Rails environment.I suggest something like below
The text was updated successfully, but these errors were encountered: