Skip to content

Commit

Permalink
Merge pull request #741 from sul-dlss/caching
Browse files Browse the repository at this point in the history
Handle Apache modification of etag header.
  • Loading branch information
justinlittman authored Oct 26, 2023
2 parents 79b08ba + 6596361 commit 96dfe59
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/purl_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class PurlController < ApplicationController
before_action :load_purl, except: [:index]
before_action :fix_etag_header

rescue_from PurlResource::DruidNotValid, with: :invalid_druid
rescue_from PurlResource::ObjectNotReady, with: :object_not_ready
Expand Down Expand Up @@ -67,4 +68,9 @@ def load_purl
def missing_file
render '/errors/missing_file', status: :not_found
end

def fix_etag_header
# Apache adds -gzip to the etag header, which causes the request appear stale.
request.headers['HTTP_IF_NONE_MATCH'].sub!('-gzip', '') if request.if_none_match
end
end

0 comments on commit 96dfe59

Please sign in to comment.