]> cat aescling's git repositories - mastodon.git/commitdiff
Explicitly disable storage of REST API results (#10655)
authorThibG <thib@sitedethib.com>
Fri, 3 May 2019 18:39:19 +0000 (20:39 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 3 May 2019 18:39:19 +0000 (20:39 +0200)
Fixes #10652

app/controllers/api/base_controller.rb
app/controllers/api/v1/custom_emojis_controller.rb
app/controllers/api/v1/instances/activity_controller.rb
app/controllers/api/v1/instances/peers_controller.rb
app/controllers/api/v1/instances_controller.rb

index 3a92ee4e4d7a6ebaa57a2f43178541151b86bc6b..eca558f4216ee1f8e565867a6dfe39ee5420463b 100644 (file)
@@ -9,6 +9,8 @@ class Api::BaseController < ApplicationController
   skip_before_action :store_current_location
   skip_before_action :check_user_permissions
 
+  before_action :set_cache_headers
+
   protect_from_forgery with: :null_session
 
   rescue_from ActiveRecord::RecordInvalid, Mastodon::ValidationError do |e|
@@ -88,4 +90,8 @@ class Api::BaseController < ApplicationController
   def authorize_if_got_token!(*scopes)
     doorkeeper_authorize!(*scopes) if doorkeeper_token
   end
+
+  def set_cache_headers
+    response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
+  end
 end
index 7bac27da4b78dd3689f16794751c525f1870e029..1bb19a09d33ec4e3581f245154a001d2713b96d6 100644 (file)
@@ -3,6 +3,8 @@
 class Api::V1::CustomEmojisController < Api::BaseController
   respond_to :json
 
+  skip_before_action :set_cache_headers
+
   def index
     render_cached_json('api:v1:custom_emojis', expires_in: 1.minute) do
       ActiveModelSerializers::SerializableResource.new(CustomEmoji.local.where(disabled: false), each_serializer: REST::CustomEmojiSerializer)
index e14e0aee8341c1d7819b50f6f51ac2ebb0caac62..09edfe365b07df3c057e3ca63f5dcb2a0c973ac3 100644 (file)
@@ -2,6 +2,7 @@
 
 class Api::V1::Instances::ActivityController < Api::BaseController
   before_action :require_enabled_api!
+  skip_before_action :set_cache_headers
 
   respond_to :json
 
index 2070c487df12bfc3f9d46e3bca623166d76ff4a5..a8891d126bfd379895bc9eeea87b691d7ba926cc 100644 (file)
@@ -2,6 +2,7 @@
 
 class Api::V1::Instances::PeersController < Api::BaseController
   before_action :require_enabled_api!
+  skip_before_action :set_cache_headers
 
   respond_to :json
 
index 5686e8d7c394e5a5c510fd0e28a465f133c68204..8c83a180149cab1a7b85e62a1c2ce35fdd798fd1 100644 (file)
@@ -2,6 +2,7 @@
 
 class Api::V1::InstancesController < Api::BaseController
   respond_to :json
+  skip_before_action :set_cache_headers
 
   def show
     render_cached_json('api:v1:instances', expires_in: 5.minutes) do