mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
nginx is stripping ETags, just use last modified instead
This commit is contained in:
@ -2,13 +2,19 @@ class SiteCustomizationsController < ApplicationController
|
||||
skip_before_filter :preload_json, :check_xhr, :redirect_to_login_if_required
|
||||
|
||||
def show
|
||||
version = params["v"]
|
||||
cache_time = request.env["HTTP_IF_MODIFIED_SINCE"]
|
||||
cache_time = Time.rfc2822(cache_time) rescue nil if cache_time
|
||||
stylesheet_time = SiteCustomization.where(key: params[:key].to_s).pluck(:created_at).first
|
||||
|
||||
if version && version == request.headers['If-None-Match']
|
||||
if !stylesheet_time
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
|
||||
if cache_time && stylesheet_time <= cache_time
|
||||
return render nothing: true, status: 304
|
||||
end
|
||||
|
||||
response.headers["ETag"] = version if version
|
||||
response.headers["Last-Modified"] = stylesheet_time.httpdate
|
||||
expires_in 1.year, public: true
|
||||
render text: SiteCustomization.stylesheet_contents(params[:key], params[:target] == "mobile" ? :mobile : :desktop),
|
||||
content_type: "text/css"
|
||||
|
Reference in New Issue
Block a user