From 82003ca1bf299b4d63e112bae7a3925a6c996927 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Wed, 13 Jul 2016 14:22:28 +0200 Subject: [PATCH] Define cache expire times for JSON requests JSON requests are very expensive. Make sure they are cached for long enough. --- app/controllers/json_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/json_controller.rb b/app/controllers/json_controller.rb index 9db5d5e..95f9c6e 100644 --- a/app/controllers/json_controller.rb +++ b/app/controllers/json_controller.rb @@ -1,21 +1,25 @@ class JsonController < ApplicationController # JSON information on a single package def package + expires_in 1.hours, public: true @p = Package.find_by_name! params[:name] end # JSON information on all packages def packages + expires_in 1.days, public: true @p = Package.all end # JSON information on all screenshots def screenshots + expires_in 1.days, public: true @s = Screenshot.includes(:package) end # JSON list of packages that do not have screenshots def packages_without_screenshots + expires_in 1.hours, public: true @p = Package.without_screenshots.all end end