Modernizr 是否在每个页面请求上创建一个新的会话存储表/对象?
之前调试应用程序时,我在 Web Inspector 中注意到,似乎每个请求都会创建一个新的会话存储对象(表?)。
屏幕截图:
您会在资源 -> 下注意到会话存储有多个 test.localhost 条目。
因此,我的注意力从实际要调试的内容上分散了注意力,并继续搜索以找出导致此问题的原因。我将范围缩小到页面上包含 Modernizr.js 的时间。
我一直在各种不同的应用程序中使用 Html5 Boilerplate 所以我回到了裸样板代码并得到了那里也有同样的行为。
请注意,上面的屏幕截图来自标准样板代码,没有其他内容。
那么,这是标准行为吗?这是我应该关心的事情吗?我当然没有注意到任何性能问题,即使在一次使用我的应用程序几个小时之后也是如此。
作为参考,我正在运行:
Safari (5.1.2)
狮子 (10.7.2)
最新的样板代码(提交 9feb29f4654540297e358454b821b2e29b848be8)
While debugging an application earlier, I noticed in Web Inspector that it appears a new session storage object (table?) was being created on every request.
Screenshot:
You'll notice under Resources -> Session Storage there are multiple entries for test.localhost.
So, I got distracted from what I was actually meant to be debugging and went on a search to find out what was causing this. I narrowed it down to when Modernizr.js is included on the page.
I've been using the Html5 Boilerplate in various different applications so I went back to the bare boilerplate code and am getting the same behaviour there as well.
Note, the screen shot above is from the standard boilerplate code, nothing else.
So, is this standard behaviour? Is it something I should be concerned about? I've certainly not noticed any performance issues, even after using my applications for a few hours at a time.
For reference, I'm running:
Safari (5.1.2)
Lion (10.7.2)
Latest boilerplate code (commit 9feb29f4654540297e358454b821b2e29b848be8)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Safari 中开发人员工具中的一个错误,已在最新的 WebKit nightly 版本中修复。
严格来说,这并不是因为包含 Modernizr,而是因为它使用
window.sessionStorage
来缓存其结果以供将来使用。每当您重新加载使用
window.sessionStorage
的页面(无论是否为 Modernizr)时,开发工具中的会话存储列表中都会出现另一个条目。使用window.localStorage
和 WebSQL 数据库观察到相同的行为。This is a bug in the developer tools in Safari, it has been fixed in more recent WebKit nightly builds.
It's not strictly caused by the inclusion of Modernizr, but by it's use of
window.sessionStorage
to cache its results for future use.Any time you reload a page that uses
window.sessionStorage
(Modernizr or not) another entry appears on the Session Storage list in the dev tools. Same behaviour is observed usingwindow.localStorage
and WebSQL databases.