mirror of
https://github.com/System-End/cdn.git
synced 2026-04-19 15:18:15 +00:00
cache?
This commit is contained in:
parent
2ae7d0e07c
commit
ce0998b5ba
2 changed files with 4 additions and 2 deletions
|
|
@ -5,7 +5,8 @@ class ExternalUploadsController < ApplicationController
|
|||
|
||||
def show
|
||||
upload = Upload.includes(:blob).find(params[:id])
|
||||
redirect_to upload.blob.url(disposition: :inline, filename: upload.filename), allow_other_host: true
|
||||
expires_in ActiveStorage.service_urls_expire_in, public: true
|
||||
redirect_to upload.blob.url(disposition: :inline), allow_other_host: true
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
head :not_found
|
||||
end
|
||||
|
|
@ -21,6 +22,7 @@ class ExternalUploadsController < ApplicationController
|
|||
upload = Upload.includes(:blob).find_by(original_url: url)
|
||||
|
||||
if upload
|
||||
expires_in ActiveStorage.service_urls_expire_in, public: true
|
||||
redirect_to upload.cdn_url, allow_other_host: true
|
||||
else
|
||||
render_not_found_response(url)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ module CDN
|
|||
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
||||
config.autoload_lib(ignore: %w[assets tasks])
|
||||
|
||||
config.active_storage.urls_expire_in = 1.month
|
||||
config.active_storage.service_urls_expire_in = 7.days
|
||||
|
||||
config.active_record.encryption.primary_key = ENV["ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY"]
|
||||
config.active_record.encryption.deterministic_key = ENV["ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue