Some of the users of our Ruby on Rails app have complained that page requests occasionally hang indefinitely under Safari (a couple have noticed it under Firefox, but it's overwhelmingly Safari users). After some investigation it seems that these requests are being served correctly by our Rails application and the hang occurs when fetching image assets (which are hosted on the same server) which are referenced in the HTML.
We have configured Apache to serve the image assets directly and bypass the Rails app for performance. We have also enabled gzip compression on text/javascript/css assets. Below are the relevant settings from our Apache Virtual Host configuration -- perhaps we have configured this in such a way which might explain these arbitrary hanging requests?
RewriteEngine On
# Correct behaviour of IE under SSL
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
SSLEngine On
SSLCertificateFile /etc/httpd/conf/ssl/_.mycert.com.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl/_. mycert.com.key
SSLCertificateChainFile /etc/httpd/conf/ssl/gd_bundle.crt
RequestHeader set X_ORIGINAL_PROTOCOL 'https'
RequestHeader set X_FORWARDED_PROTO 'https'
# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]
RewriteRule "^/(images|stylesheets|javascripts|system)/?(.*)" "$0" [L]
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
ExpiresActive On
<FilesMatch "\.(ico|gif|jpe?g|png|js|css)$">
ExpiresDefault "access plus 1 year"
Header append Cache-Control "public"
</FilesMatch>
Has anyone experienced a similar problem before?
Our Ruby on Rails web application runs using mod_rails and Apache 2.2.3 on RedHat Enterprise Linux 5.
Update: I have now tried removing the following block and the problem still persists, so it looks like we can exclude the expires header from being the problem:
ExpiresActive On
<FilesMatch "\.(ico|gif|jpe?g|png|js|css)$">
ExpiresDefault "access plus 1 year"
Header append Cache-Control "public"
</FilesMatch>