الهجين :: DirHandler يعادل لنقل المسافرين
-
04-07-2019 - |
سؤال
وأنا باستخدام هجين :: DirHandler للسيطرة على رؤوس استجابة لملفات ثابتة - وهذا يعمل كبيرة على الجهاز ديف بلدي. يستخدم الجهاز الخاص بي إنتاج الركاب حتى لا يحصل وضع رؤوس بلدي. كيف أتحكم في رؤوس الملفات الثابتة عند استخدام الركاب؟
والمتكررة من وجهة نظري environment.rb:
if defined? Mongrel::DirHandler
module Mongrel
class DirHandler
def send_file_with_expires(req_path, request, response, header_only=false)
if req_path =~ /((\/images)|javascripts|stylesheets)/
response.header['Cache-Control'] = 'max-age=315360000'
response.header['Expires'] = (Time.now + 10.years).rfc2822
else
response.header["Last-Modified"] = Time.now.httpdate
response.header["Expires"] = 0
# HTTP 1.0
response.header["Pragma"] = 'no-cache'
# HTTP 1.1 ‘pre-check=0, post-check=0′ (IE specific)
response.header["Cache-Control"] = 'no-store, no-cache, must-revalidate, max-age=0, pre-check=0, post-check=0'
end
send_file_without_expires(req_path, request, response, header_only)
end
alias_method :send_file_without_expires, :send_file
alias_method :send_file, :send_file_with_expires
end
end
end
المحلول
ومنذ كنت تستخدم الركاب، وأفترض أنك تحت اباتشي، لذلك طلبك لا يمر هجين بعد الآن. إذا كان الأمر كذلك، يمكنك وضع قواعد على الملف .htaccess
داخل الدليل public
من التطبيق الخاص بك.
لا تنتمي إلى StackOverflow