我如何为不在服务器上的脚本添加过期头文件?

编程入门 行业动态 更新时间:2024-10-25 22:30:48
本文介绍了我如何为不在服务器上的脚本添加过期头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

例如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.

更多推荐

我如何为不在服务器上的脚本添加过期头文件?

本文发布于:2023-10-31 19:14:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547022.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:何为   脚本   头文件   器上

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!