iphone 微信缓存

2010 update: Lo, the Web Performance Advent Calendar hath moved

2010年更新: Lo, Web Performance Advent Calendar已移动

Dec 22 This post is part of the 2009 performance advent calendar experiment. Stay tuned for the articles to come - only 2 to go!

12月22日这篇文章是2009年性能出现日历实验的一部分。 请继续关注本文,仅2件!

Some time ago there was a post on YUIBlog highlighting the findings of Wayne Shea and Tenni Theurer on the caching behavior of the iPhone. Curious if things have changed several iPhone OS updates later, I ran some experiments with OS3 and OS3.1.

前一段时间,YUIBlog上有一篇文章重点介绍了Wayne Shea和Tenni Theurer在iPhone缓存行为方面的发现。 奇怪的是,事后是否更改了多个iPhone OS更新,我对OS3和OS3.1进行了一些实验。

强调 (Highlights)

  • iPhone will not cache components bigger than 15K (was 25K in the previous experiment)iPhone不会缓存大于15K的组件(在先前的实验中为25K)
  • total cache is about 1.5MB (was 500K)总缓存约为1.5MB(原为500K)
  • short-term memory cache will store components up to 1941K provided the component size does not divide by 4短期内存缓存将最多存储1941K的组件,前提是组件的大小不除以4
  • powering off the device still clears all the cache, Expires headers still important关闭设备电源仍会清除所有缓存,Expires标头仍然很重要
  • not sure since when, but closing all tabs clears the cache too不知道从什么时候开始,但是关闭所有选项卡也会清除缓存
  • consider HTML5 application cache to improve cacheability and provide offline experience – components in the application cache can be bigger than 15K and stay cached even after you clear Safari's cache from the Settings app (or clear it any other way)考虑使用HTML5应用程序缓存来提高可缓存性并提供脱机体验-即使从“设置”应用程序清除Safari的缓存(或以其他任何方式清除),应用程序缓存中的组件也可能大于15K并保持缓存状态

15是新的25(15 is the new 25)

Previous experiment showed that the iPhone will not cache components bigger that 25K, but this number is now down to 15K. And this is ungzipped size, meaning if you have for example a 20K JavaScript and your server sends it gzipped down to 10K, it will not be cached by the iPhone.

先前的实验表明,iPhone不会缓存大于25K的组件,但现在该数量已降至15K。 这是未压缩的大小,这意味着,例如,如果您有20K JavaScript,并且您的服务器将其压缩到10K,它将不会被iPhone缓存。

So minification can definitely help you here. Minification may not be as beneficial as gzipping in desktop browsers, but it may be the difference between a cache hit or miss in the iPhone. Minify, then gzip. And, in general, try to keep your component sizes low - that always helps in any browser.

因此,缩小绝对可以在这里为您提供帮助。 缩小可能不像在桌面浏览器中gziping那样有益,但可能是iPhone中缓存命中或未命中的区别。 缩小,然后压缩。 而且,一般来说,请尽量减小组件的尺寸-这在任何浏览器中总是有帮助的。

总缓存大小 (Total cache size)

First off, how was the experiment run? I simply tailed the access log of a server, in order to monitor which components get requested:

首先,实验是如何进行的? 我只是添加了服务器的访问日志,以监视请求了哪些组件:

$ tail -f ~/logs/http/access.log | grep "XXX.YYY.ZZZ.000"

Where XXX.YYY.ZZZ.000 is the IP address. You can also replace that with just "iPhone" if you think no one else is hitting this site with an iPhone.

其中XXX.YYY.ZZZ.000是IP地址。 如果您认为没有其他人用iPhone登陆该网站,则也可以仅用“ iPhone”代替。

Then I requested components with different sizes and look at what the log tail says.

然后,我要求使用不同尺寸的组件,并查看原木尾巴上的内容。

Once it was clear that 15K is the maximum components size, the next question was how many of those 15K components can be cached before iPhone runs out of space allocated for caching? And the result was 105. Attempting to cache one more file resulted in removing existing ones from the cache. Then playing with the size of the very last component helped nail the exact number of bytes available in the cache – 105 * 15 + 7 = 1582K.

一旦明确知道最大组件大小为15K,下一个问题是在iPhone用完用于缓存的空间之前,可以缓存这15K组件中的多少个? 结果为105。尝试再缓存一个文件会导致从缓存中删除现有文件。 然后,使用最后一个组件的大小可以帮助确定高速缓存中可用的确切字节数– 105 * 15 + 7 = 1582K。

So the total cache is just a little over 1.5 MB (earlier research showed 0.5MB for earlier iPhone OS). Have in mind that this is the total cache shared between all pages, it's not per domain or per tab.

因此,总缓存仅略高于1.5 MB(早期的研究表明,较早的iPhone OS为0.5MB)。 请记住,这是所有页面之间共享的总缓存,而不是每个域或每个选项卡。

内存缓存 (Memory cache)

The iPhone has a little bit more cache space in the form of memory cache. The memory cache has no per-component size limit, so your components can be as big as the memory cache – 1941 bytes (don't ask how many attempts it took to nail this number).

iPhone具有内存缓存形式的更多缓存空间。 内存缓存没有每个组件的大小限制,因此您的组件可以和内存缓存一样大-1941字节(不要问要为该数字指定多少次尝试)。

There a little catch though, probably due to a bug, and it's that if the component size divides by 4, it won't be cached in memory. That's true for JavaScripts – they will be requested on every page load. CSS files with sizes over 15 that divide by 4 will not be requested in the same tab session, but if you close the tab and open the page in another tab, they will be requested again.

但是,有一个小问题,可能是由于错误所致,它是如果组件大小除以4,则不会将其缓存在内存中。 对于JavaScript来说确实如此-每次加载页面时都会请求它们。 超过15CSS文件除以4CSS文件不会在同一选项卡会话中被请求,但是如果您关闭该选项卡并在另一个选项卡中打开页面,则将再次请求它们。

So components under 15K go to the disk cache, a 16K component is never cached (so is 20, 24, …, 36,.. 100,… 1024 and so on), 17K and up (up to almost 2 megs) components are cached in memory.

因此,低于15K的组件将进入磁盘缓存,永远不会缓存16K的组件(因此20、24,…,36,.. 100,…1024等),17K及以上(最多2兆)的组件缓存在内存中。

This memory cache is very unreliable as you can guess, because it gets cleared very often, it's probably useful only in the same user session on your web site.

您可能猜到,此内存缓存非常不可靠,因为它经常被清除,它可能仅在网站上的同一用户会话中有用。

一些观察 (Some observations)

  • Closing all tabs, except for blank ones (as when you do "New Page") and then closing Safari is the same as clearing the cache from Settings. So it's a good idea in your normal daily use to leave at least one page open, before you close Safari in order not to cause the implicit cache clearing.关闭所有选项卡(空白选项卡除外)(如执行“新建页面”时一样),然后关闭Safari,与从“设置”中清除缓存相同。 因此,在日常使用中,最好在关闭Safari之前至少打开一个页面,以免导致隐式缓存清除。
  • Tapping the reload icon in the address bar sends unconditional requests for all components, without the If-Modified-Since header and ignoring the Expires header. So to speed up your browsing, refresh the page by tapping the address bar and then tapping GO, don't use the refresh icon.

    轻触地址栏中的重新加载图标可发送所有组件的无条件请求,而无需If-Modified-Since标头,而忽略Expires标头。 因此,为了加快浏览速度,请通过点按地址栏然后点按“ GO”来刷新页面,请不要使用刷新图标。

  • The tests I ran were using OS 3.0 and OS 3.1.2. I got my phone last Christmas which means that according to this page it came with OS 2.2. I don't remember if I ran any tests with OS2.2. too. I do remember though that I tried some tests back when I didn't have a phone and asked help from Ryan Grove and Nicole Sullivan. Chatting over IM they were loading pages while I was tail-ing the server log. Those tests must have been with OS 2 or OS2.1. Back then the results showed that the limit for a component that gets stored in the cache was 10Meg, which was also the total size of the cache. Now I have my doubts that back then we only tested memory cache, not disk cache. In any event, it's important to note that those restrictions are all software restrictions. No matter what model the phone, it's the OS that sets the limits. Different models with the same OS will behave the same when it comes to caching sizes.

    我运行的测试是使用OS 3.0和OS 3.1.2。 去年圣诞节我拿到了手机,这意味着根据此页面,该手机随附OS 2.2。 我不记得我是否在OS2.2上进行过任何测试。 太。 我确实记得,当我没有手机时我曾尝试过一些测试,并要求瑞安格罗夫( Ryan Grove)和妮可•沙利文( Nicole Sullivan)的帮助。 当我跟踪服务器日志时,通过IM聊天他们正在加载页面。 这些测试必须在OS 2或OS2.1上进行。 当时的结果表明,存储在缓存中的组件的限制为10Meg,这也是缓存的总大小。 现在我有疑问,那时候我们只测试了内存缓存,而不是磁盘缓存。 无论如何,必须注意这些限制都是软件限制。 不管手机是什么型号,都由操作系统来设置限制。 具有相同操作系统的不同型号在缓存大小方面的行为相同。

HTML5离线应用程序缓存 (HTML5 offline application cache)

All in all we can safely summarize that the iPhone has no cache to speak of. 15K per component is nothing and the limit of 1.5Megs shared with all other pages will have your cached components kicked out pretty quickly.

总而言之,我们可以安全地总结出iPhone没有缓存可言。 每个组件15K没什么,与所有其他页面共享的1.5Meg限制将使您缓存的组件很快被淘汰。

So – what's an iPhone performance optimizer to do? Use HTML5 goodies.

那么– iPhone性能优化器是做什么的? 使用HTML5好吃的东西。

One thing to consider is some form of client storage supported by the mobile webkit (either key-value or SQLite), but that will require some of your javascript to handle the caching, expiration and so on.

要考虑的一件事是移动Webkit支持的某种形式的客户端存储(键值或SQLite),但这将需要您的一些javascript来处理缓存,到期等。

Another thing to do is use the offline application cache. It's meant to support applications to work offline, but it also ends up being useful to improve caching of online applications as well.

另一件事是使用脱机应用程序缓存。 它旨在支持应用程序脱机工作,但最终也有助于改善在线应用程序的缓存。

What you need is a simple text file called a manifest. In there you list all the components required by your application. E.g.

您需要一个称为清单的简单文本文件。 在其中列出了应用程序所需的所有组件。 例如

CACHE MANIFEST
/root/path/to/images/image.jpg
or/maybe/relative/paths/too/scripts.js
http://example.org/good-old/absolute/path/oojs-home.jpg

It's important to serve this file with content type text/cache-manifest.

使用内容类型text/cache-manifest来提供此文件很重要。

Then in your html tag just point to that file. Let's say you called the manifest mycache.manifest (could be dynamic, php, or anything, as long as it's served with the proper content type). So your HTML should start like the following:

然后在您的html标记中html向该文件。 假设您调用了清单清单mycache.manifest (可以是动态的,php或其他任何形式,只要它具有正确的内容类型即可)。 因此,您HTML应该像下面这样开始:

<!DOCTYPE html>
<html manifest="mycache.manifest">

And this is it. There's also JavaScript API available if you want to play with the items stored in the cache.

就是这样。 如果您想使用缓存中存储的项目,还可以使用JavaScript API。

Now the browser will request the manifest file every time (Expires header won't help you here) and if its contents is changed it will quietly and unobtrusively download the updated components in the background and the next time the user will see the updated page. Needless to say it makes sense that all the pages of the site share the same manifest.

现在,浏览器每次都会请求清单文件(Expires标头在这里无济于事),如果其内容发生更改,它将在后台安静且毫不干扰地下载更新的组件,而下次用户将看到更新的页面。 不用说,站点的所有页面共享同一清单是有意义的。

The best part is that when using offline cache none of the restrictions mentioned above apply – you can store files bigger than 15K and you don't share your total cache space with anyone.

最好的部分是,使用脱机缓存时,上述任何限制均不适用–您可以存储大于15K的文件,并且不与任何人共享总缓存空间。

I used this for a personal project – whomsy.com if you want to play with some requests and monitor the traffic (e.g. using the iPhone simulator and Charles proxy).

我将此用于个人项目– whosy.com(如果您想处理一些请求并监控流量)(例如,使用iPhone模拟器和Charles代理)。

清单–不仅限于iPhone? (Manifest – not just for iPhone?)

The manifest idea sounds so nice, it makes sense to apply it to desktop browsers as well. In a way it's similar to the idea of having web archives – a zip with all page components (sorry, can't find the URL for the proposal for web archives right now). You can include the manifest on your homepage and, after onload, the browser preloads all the other components used by internal pages (no need to do preloading yourself in JavaScript, no need to worry about spriting images and so on). This is absolutely doable and it also provides the side benefit that your app is available offline, which is the original purpose of the offline cache

iphone 微信缓存_iPhone缓存相关推荐

  1. 前端——解决微信网页清除缓存的方法

    前端--解决微信网页清除缓存的方法 参考文章: (1)前端--解决微信网页清除缓存的方法 (2)https://www.cnblogs.com/fkcqwq/p/9604184.html 备忘一下.

  2. 同时存多个变量缓存 微信小程序_微信小程序 缓存(本地缓存、异步缓存、同步缓存)详解...

    微信小程序 缓存 关于本地缓存 1.wx.setStorage(wx.setStorageSync).wx.getStorage(wx.getStorageSync).wx.clearStorage( ...

  3. 微信小程序开发工具 清除授权缓存/文件缓存/登录缓存等等

    今天2.19.3.25 在开发微信小程序时,作为测试号想清除授权缓存,一直没有找到方法, 最后无意中看到了解决方法 微信小程序开发工具 清除授权缓存/文件缓存/登录缓存等等.完美解决

  4. 本地缓存需要高时效性怎么办_详解微信小程序缓存--缓存时效性

    关于本地缓存 1.wx.setStorage(wx.setStorageSync).wx.getStorage(wx.getStorageSync).wx.clearStorage(wx.clearS ...

  5. 微信html页面缓存问题,浅谈微信页面入口文件被缓存解决方案_简单_前端开发者...

    缓存对于前端页面来说,是加速页面加载的利器之一,但也同时带来了很多问题,比如新版本发布之后,怎么替换客户端上的缓存文件呢?大家一般的的解决方案主要有以下几种形式, 一般情况 1.添加版本号,在静态 l ...

  6. php微信网页不缓存,微信浏览器取消缓存的方法

    这篇文章主要介绍了微信浏览器取消缓存的方法,本文使用meta头信息实现取消了微信浏览器的缓存,特别是在开发时会经常用到,需要的朋友可以参考下. 做微信公众号和调试手机页面的时候,避免不了页面要跳转到微 ...

  7. vue项目微信端清理缓存问题解决

    vue项目微信端清理缓存问题解决 参考文章: (1)vue项目微信端清理缓存问题解决 (2)http://www.cnblogs.com/sakura-lifangfang/p/9660550.htm ...

  8. 清理微信浏览器网页缓存的办法

    微信开发是件非常蛋疼的事情,微信网页的缓存是更加蛋疼的东西,今天遇到的问题:一个页面在web开发工具上可以正常授权并获取到openid,放在手机上就死活不行,网上找来的办法如下: 使用微信内置的浏览器 ...

  9. 小程序怎么清服务器缓存,怎么清理微信小程序缓存 微信小程序缓存删除的方法...

    微信小程序上线之后,关注的小程序越多,哪么将占用的手机空间就越大,这些程序会产生一定的缓存,那么怎么清理小程序缓存呢?微信小程序内的缓存到底如何清除?和小编一起来看看删除微信小程序缓存的方法吧. 一些 ...

最新文章

  1. 进程状态控制-进程的挂起和激活
  2. SQL Server 常用系统函数和修改字符约束(collate)的修改
  3. [VB] Option Explicit
  4. 干式双离合和湿式双离合的优缺点
  5. 35岁大龄程序员都去哪了?一位网友分享的身边几个真实案例,过于真实!!
  6. 免费申请 Office365 E5 开发者订阅
  7. CPU高速缓存SRAM命中问题的总结与实验
  8. a span做成按钮样式不选中文字
  9. 《Fortran95程序设计》(彭国伦)
  10. R语言|根据列名提取/筛选列的两种方法
  11. 路由器拨号服务器响应怎么解决,路由器无法拨号,并且服务器没有响应。
  12. Javascript代码优化的8个知识点,分享web前端资料
  13. 行走的Offer收割机,首次公布Java10W字面经,Github访问量破百万
  14. ACM-ICPC 2018 南京赛区网络预赛 J Sum(欧拉线性筛+思维)
  15. 计算机科学与技术的班徽设计,地球科学与技术学院 2017级班级班徽创意设计大赛获奖公示...
  16. 直播软件开发Android直播悬浮窗实现
  17. Multi-Stage Feature Fusion Network for Video Super-Resolution阅读笔记
  18. 2021-09-06《黄金交易策略》黄金走势分析!黄金今日操作建议解套策略
  19. 学 Frida 安卓逆向之快速搭建 Frida 安卓逆向环境
  20. docsify笔记 02:主题、插件与其它个性化设置

热门文章

  1. 使用GeoServer发布你的第一个网络地图服务
  2. python访问共享文件夹 exist false_pythonos.path.exists()存在的nfs装载目录文件失败...
  3. font属性、字体、文本样式的介绍以及使用方法
  4. 实用!有效提升网站应用安全性的10项措施,记得收藏!
  5. 计算机cmd如何设置路由,将windows7电脑改造成无线路由器怎么操作
  6. MKVToolnix 视频制作和DTS 音轨转换
  7. 计算机二级比赛新闻稿,篮球比赛新闻稿(范文)-20210723061015.doc-原创力文档
  8. 计算机毕业设计SSM-Java网名推荐系统【附源码数据库】
  9. 如何批量将 webp 格式图片转换为 png 格式
  10. 用Qt将一组静态连续图片制作成动图(定时器和QPixmap实现)