【问题标题】:File Downloads in Internet Explorer over SSL in Rails通过 Rails 中的 SSL 在 Internet Explorer 中下载文件
【发布时间】:2023-03-11 14:39:01
【问题描述】:

最近将我的 Rails 3.0 应用程序切换到 SSL 后,我在 Internet Explorer 中下载文件时遇到了问题。在 Firefox 和 Chrome 中一切正常。经过大量搜索,我相当确信该问题与 Cache-Control HTTP 响应标头有关。

所以在代码中,我在调用 send_file 之前手动删除了 Cache-Control 和 Pragma。

response.headers.delete("Pragma")
response.headers.delete('Cache-Control')
send_file(response_letter_path, :filename=>"aod_response_letter.docx", :disposition=>'inline')

但是当我使用 Firebug 或 Chrome 开发工具查看 HTTP 响应时,它仍然显示“Cache-Control:private”。

首先,我是否在解决这个 IE 问题的正确轨道上?其次,这是从 HTTP 响应中删除标头的正确方法吗?

谢谢!

【问题讨论】:

    标签: ruby-on-rails internet-explorer http ssl download


    【解决方案1】:

    是的,你在正确的轨道上。

    我刚刚遇到这个问题,并通过在 send_file 调用之前添加以下行来解决它。 response.headers.delete('Cache-Control')

    Rails 默认设置 HTTP 标头 Cache-Control: no-cache。由于 IE 使用磁盘缓存播放视频,所以会抛出“找不到播放文件”的错误。

    【讨论】:

      猜你喜欢
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-10
      • 2018-11-01
      • 1970-01-01
      • 2021-03-05
      相关资源
      最近更新 更多