mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Increase time of DOWNLOAD_URL_EXPIRES_AFTER_SECONDS to 5 minutes (#10160)
* Change S3Helper::DOWNLOAD_URL_EXPIRES_AFTER_SECONDS to 5 minutes, which controls presigned URL expiry and secure-media route cache time. * This is done because of the composer preview refreshing while typing causes a lot of requests sent to our server because of the short URL expiry. If this ends up being not enough we can always increase the time or explore other avenues (e.g. GitHub has a 7 day validity for secure URLs)
This commit is contained in:
@@ -153,8 +153,9 @@ class UploadsController < ApplicationController
|
||||
return render_404 if current_user.nil?
|
||||
end
|
||||
|
||||
# defaults to public: false, so only cached by the client browser
|
||||
cache_seconds = S3Helper::DOWNLOAD_URL_EXPIRES_AFTER_SECONDS - SECURE_REDIRECT_GRACE_SECONDS
|
||||
expires_in cache_seconds.seconds # defaults to public: false, so only cached by the client browser
|
||||
expires_in cache_seconds.seconds
|
||||
|
||||
# url_for figures out the full URL, handling multisite DBs,
|
||||
# and will return a presigned URL for the upload
|
||||
@@ -162,7 +163,9 @@ class UploadsController < ApplicationController
|
||||
return redirect_to Discourse.store.url_for(upload)
|
||||
end
|
||||
|
||||
redirect_to Discourse.store.signed_url_for_path(path_with_ext)
|
||||
redirect_to Discourse.store.signed_url_for_path(
|
||||
path_with_ext, expires_in: S3Helper::DOWNLOAD_URL_EXPIRES_AFTER_SECONDS
|
||||
)
|
||||
end
|
||||
|
||||
def metadata
|
||||
|
||||
Reference in New Issue
Block a user