diff options
author | Hans de Graaff <graaff@gentoo.org> | 2019-07-22 17:27:57 +0200 |
---|---|---|
committer | Hans de Graaff <graaff@gentoo.org> | 2019-07-22 17:27:57 +0200 |
commit | 2fdc6183dd5fb75121149a03cdfbe98b6453af6f (patch) | |
tree | 3637d53ea812b6b8607600a368b91a49b569687f | |
parent | Fix deprecation of positional arguments in controller tests (diff) | |
download | packages-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.rb | 4 |
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 = ' 📦 %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 |