我如何为不在服务器上的脚本添加过期头文件? [英] How can I add expire headers for scripts that are not on my server?

查看:95
本文介绍了我如何为不在服务器上的脚本添加过期头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,并且在所有页面/图像和脚本上添加了过期标题,但我不知道如何将过期标题添加到外部脚本。

例如Google Analytics(分析) - 它已将过期的标题设为1天。



Google不是我的问题,外部网站的其他脚本是真正的问题,它们根本没有过期头文件。

解决方案

您只能添加标题字段,以响应发送到您自己的服务器的请求。如果请求发送到另一台服务器,比如说Google的服务器,那么它的响应速度就会比Google服务器的响应速度快。



因此,解决您的问题的唯一方法就是将您的外部资源托管在您的拥有服务器。但是这只有在资源是静态的时候才可能发生,不要求从请求到请求,也不要依赖于其他东西。


I have a website and I added the expire headers on all pages/images and scripts but I don’t know how I could add expire headers to external scripts.

For example Google Analytics - it has expire headers set to 1 day.

Google is not my problem, some other scripts from external websites are the real problem, they don't have expire headers at all.

解决方案

You can only add header fields in responses to requests that go to your own server. If the request goes to another server, say Google’s server, than it’s Google’s server that answers the request.

So the only solution to your problem is hosting that external resources on your own server. But that’s only possible if that resources are static, do not change from request to request and do not depend on other things.

这篇关于我如何为不在服务器上的脚本添加过期头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆