Last active
August 29, 2015 14:02
-
-
Save gregawoods/071a8994cabc38dd786f to your computer and use it in GitHub Desktop.
Resolve issue where Safari 7 and iOS 7 Mobile Safari incorrectly render cached pages when a 304 response is returned from the server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_filter :delete_if_none_match_header | |
private | |
# Encountered bug where Safari 7 would fail to render pages when ETAG-based caching kicks in | |
# This should prevent Safari from attempting such caching | |
def delete_if_none_match_header | |
if request.format.html? && request.headers['If-None-Match'] != nil && is_safari?() | |
request.headers['If-None-Match'] = nil | |
end | |
end | |
def is_safari? | |
ua = request.env['HTTP_USER_AGENT'] | |
return (ua.match('Intel Mac OS X') || ua.match('iPhone OS')) && ua.match('Safari') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For more info: IOS7-BUG: SHOWS WHITE PAGE WHEN GETTING 304 NOT MODIFIED FROM SERVER