让 Mongrel/WEBRick 为静态资产提供未来过期标头
我正在创建一个 Rails 应用程序,它将部署到桌面计算机上,同时运行网络服务器和浏览器(这是一个测试应用程序,需要能够在没有互联网连接的情况下运行)。
因此,我将运行 Mongrel 或 WEBRick,而不像通常那样在其前面放置 Apache/Nginx。浏览器将直接访问 Mongrel。
我现在面临的问题是加载资源(javascript/样式表/图像)需要一段时间。通常,我会通过在 Mongrel/WEBRick 前面的 Apache 代理中设置这些资产的未来到期日期来解决此问题,以便这些资产仅被请求一次,之后每个操作只有一个请求。
但在这种情况下,没有代理,并且我使用 config.serve_static_assets = true
所以问题是:是否可以告诉 Mongrel/WEBrick 在静态上打上远期到期标头资产?
我在 Ruby 1.9.2 上使用 Rails 3。
I'm creating a Rails application which will be deployed to desktop machines, running both the webserver and the browser (it's a test-taking application which needs to be able to run without an internet connection).
For this reason, I'll be running Mongrel or WEBRick, without an Apache/Nginx in front of it as you would normally do. The browser will access the Mongrel directly.
The problem I'm facing now is that it takes a while to load assets (javascript/stylesheets/images). Normally, I'd fix this by setting future expiry dates on these assets in the Apache proxy in front of the Mongrel/WEBRick, so that the assets are only requested once, and after that there is only one request per action.
But in this case, there is no proxy, and i'm using config.serve_static_assets = true
So the question is: is it possible to tell Mongrel/WEBrick to slap far-future expiry headers on the static assets?
I'm using Rails 3 on Ruby 1.9.2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以尝试这样的事情:
you can try something like this :