Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何缓存另一个站点iframe?_Javascript_Php_Jquery_Caching_Iframe - Fatal编程技术网

Javascript 如何缓存另一个站点iframe?

Javascript 如何缓存另一个站点iframe?,javascript,php,jquery,caching,iframe,Javascript,Php,Jquery,Caching,Iframe,我的网站从另一个网站加载iframe。我想缓存此iframe,然后加载缓存副本 不幸的是,我不能使用nginx,这就是为什么我对如何使用php/js/ajax/xml或其他东西缓存iframe感兴趣 可能是这样的: - create iframe.php file on server with loading another site iframe - iframe.php load iframe first time, than cache it - include iframe.php

我的网站从另一个网站加载iframe。我想缓存此iframe,然后加载缓存副本

不幸的是,我不能使用nginx,这就是为什么我对如何使用php/js/ajax/xml或其他东西缓存iframe感兴趣

可能是这样的:

 - create iframe.php file on server with loading another site iframe
 - iframe.php load iframe first time, than cache it
 - include iframe.php where I need (but I don't 
understand how to save all native header information of another site) 
所有这些我都需要从另一个网站加载标题信息,但我不能多次加载,只需加载一次即可为新用户显示缓存


谢谢你的帮助

在客户端,您不能影响第三方页面导航器的缓存行为

如果要在服务器端缓存页面,服务器端脚本必须获取页面并缓存它。iframe必须加载此脚本


我希望我回答了你的问题。不幸的是,我不太清楚。

怎么办另存为.html到您的主机帐户,然后加载到iframe。

请记住,当您使用iframe时,您的页面首先呈现,然后加载iframe页面,因此您的用户会一直看到一些东西。如果您正在通过
file\u get\u contents()
加载一个沉重的页面,则在内容完全加载之前,您的页面不会呈现,如果他们的服务器/网络/脚本速度较慢,则您的用户将受到影响,因为您的页面在PHP完成之前不会呈现。我的意思是,在服务器中另存为缓存/静态文件,然后在iframe中加载。使用cron自动更新此文件。选中它
$homepage=file\u get\u contents('https://other-site.com'); 
echo$主页-工作正常,但不保存任何标题信息,如cookies和其他。是的,cron作业将完成此任务。但是,图像和脚本呢?如果第三方站点上的图像具有相对URL(../images/1.png),则在使用HTML注入iFrame时,不会加载这些图像,因为图像路径与它们的服务器(而不是您的服务器)相关@RestStudio——确保你能正确地获取所有图片/CSS/JavaScript。@ RastWishes:你还必须考虑内容所有者可能会阻止你的IP来清除他们的数据。他们也可能对自己的交通被偷感到不高兴。使用live iFrame,第三方所有者可以将一页视图转换为一页视图。如果你刮取他们的数据来填充你自己的iFrame,他们不会获得任何页面浏览量,但你很乐意在你的网站上窃取并展示他们的创造性工作。如果是我的内容,你刮和交通你掐,我会缝你。使用这个建议时要考虑很多。