简体   繁体   English

如何在IOS safari上禁用缓存?

[英]How to disable cache on IOS safari?

Is there a way to disable caching on ipad/iphone? 有没有办法在ipad / iphone上禁用缓存? I want to run some automated tests for non-cache experience. 我想为非缓存体验运行一些自动化测试。

I just stumbled across a way to disable cache in Safari on iOS: 我偶然发现了一种在iOS上禁用缓存的方法:

iOS iOS版

  1. Open Settings 打开设置
  2. Navigate to Safari > Advanced 导航到Safari>高级
  3. Enable Web Inspector 启用Web Inspector
  4. Switch back to Safari and load a web page 切换回Safari并加载网页

Desktop 桌面

  1. Open Safari 打开Safari
  2. Navigate to Safari > Preferences > Advanced tab 导航到Safari>首选项>高级选项卡
  3. Enable the Develop menu 启用“ 开发”菜单
  4. In the Develop menu, select Your iOS Device Name > The Page You Want to Debug 在“ 开发”菜单中,选择“ 您的iOS设备名称” > “您要调试的页面”
  5. Press Command-Shift-R to reload while disabling cache 在禁用缓存时按Command-Shift-R重新加载
  6. Bonus: This is a full Web Inspector on your computer inspecting a page on your iOS device 额外奖励:这是计算机上的完整Web Inspector,用于检查iOS设备上的页面

If you want something more permanent, you'll either have to go the proxy route or make a UIWebView / WKWebView wrapper app that disables caching. 如果你想要更永久的东西,你要么必须去代理路线,要么制作一个禁用缓存的UIWebView / WKWebView包装应用程序。

There is a way to effectively disable caching on iphone/ipad/IOS. 有一种方法可以有效地禁用iphone / ipad / IOS上的缓存。

Install Fiddler on a windows desktop, and allow remote computers to connect: 在Windows桌面上安装Fiddler,并允许远程计算机连接:

在此输入图像描述

In IOS, setup a proxy under your wifi connection settings, pointing to to the IP address of the computer you are running fiddler on, and on port 8888 (assuming you haven't changed it from default in fiddler): 在IOS中,在您的wifi连接设置下设置代理,指向您正在运行fiddler的计算机的IP地址,以及端口8888(假设您没有在fiddler中将其更改为默认值):

在此输入图像描述

By now, fiddler should be intercepting all web requests your device is making. 到目前为止,fiddler应该拦截您的设备正在进行的所有Web请求。

You can now disable caching from the Rules -> Performance menu in fiddler. 您现在可以从fiddler中的Rules - > Performance菜单中禁用缓存。

在此输入图像描述

我可能是错的,但在iOS上确实将Safari置于私密浏览模式禁用缓存?

Doesn't seems like possible. 似乎不太可能。 On desktop safari, there is a option to disable cache in developer tools, however there isn't one on mobile safari. 在桌面游戏中,有一个选项可以在开发人员工具中禁用缓存,但是在移动版Safari中没有一个。 I didn't find the option in other browsers like opera neither. 我没有在其他浏览器中找到像opera这样的选项。

If you wanna try, you can overwrite a desktop firefox's user agent string and make it a fake ipad mobile browser, and then disable cache. 如果您想尝试,可以覆盖桌面firefox的用户代理字符串并使其成为虚假的ipad移动浏览器,然后禁用缓存。 But that will depends on what you want to test and it could not work at all. 但这取决于你想要测试什么,它根本无法工作。

Hope this helps. 希望这可以帮助。

Using iOS Simulator 9.0 I have been finding that both the Developer - Disable Caches menu item and Cmd-Shift-R reload have both failed to completely bypass the cache for whatever reason. 使用iOS模拟器9.0我发现开发人员 - 禁用缓存菜单项和Cmd-Shift-R重新加载都无法以任何理由完全绕过缓存。 The only thing that worked was to hold shift and press this reload button in the Safari Developer tools: 唯一有效的方法是保持shift并按下Safari Developer工具中的重新加载按钮:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM