aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Graaff <graaff@gentoo.org>2019-07-22 17:27:57 +0200
committerHans de Graaff <graaff@gentoo.org>2019-07-22 17:27:57 +0200
commit2fdc6183dd5fb75121149a03cdfbe98b6453af6f (patch)
tree3637d53ea812b6b8607600a368b91a49b569687f
parentFix deprecation of positional arguments in controller tests (diff)
downloadpackages-5-2fdc6183dd5fb75121149a03cdfbe98b6453af6f.tar.gz
packages-5-2fdc6183dd5fb75121149a03cdfbe98b6453af6f.tar.bz2
packages-5-2fdc6183dd5fb75121149a03cdfbe98b6453af6f.zip
Set ETag and Last-Modified based on package info
This should avoid stale information being reported in the browser because an older, stale but cached, version is shown. Signed-off-by: Hans de Graaff <graaff@gentoo.org>
-rw-r--r--app/controllers/packages_controller.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb
index a972fcd..67aa0af 100644
--- a/app/controllers/packages_controller.rb
+++ b/app/controllers/packages_controller.rb
@@ -25,6 +25,8 @@ class PackagesController < ApplicationController
@package = Package.find_by(:atom, params[:id])
fail ActionController::RoutingError, 'No such package' unless @package
+ fresh_when etag: @package.updated_at, last_modified: @package.updated_at
+
# Enable this in 2024 (when we have full-color emojis on a Linux desktop)
# @title = ' &#x1F4E6; %s' % @package.atom
@title = @package.atom
@@ -35,6 +37,8 @@ class PackagesController < ApplicationController
@package = Package.find_by(:atom, params[:id])
fail ActionController::RoutingError, 'No such package' unless @package
+ fresh_when etag: @package.updated_at, last_modified: @package.updated_at
+
@changelog = Rails.cache.fetch("changelog/#{@package.atom}") do
Portage::Util::History.for(@package.category, @package.name, 5)
end