Dav*_*fer 16 javascript caching google-maps google-maps-api-3
我正在为项目使用Google Maps JS API v3.有没有办法让地图在客户端的机器上缓存切片,这样当他们刷新浏览器时,瓷砖不必再次全部下载?
我的许多客户都在蜂窝连接上,重新下载地图需要相当长的时间.
谢谢!
HTML5及其缓存清单功能实际上可以实现这一点.我建议更新这个问题(和答案).
谷歌编码员自己已经解决了这个问题,遗憾的是信息传播得不好.
您的缓存文件看起来像(根据密苏里州):
CACHE MANIFEST
/map/mobile/examples/template.aspx
/map/mobile/examples/template.css
/map/mobile/examples/template.js
NETWORK:
http://maps.gstatic.com/
http://maps.google.com/
http://maps.googleapis.com/
http://mt0.googleapis.com/
http://mt1.googleapis.com/
http://mt2.googleapis.com/
http://mt3.googleapis.com/
http://khm0.googleapis.com/
http://khm1.googleapis.com/
http://cbk0.googleapis.com/
http://cbk1.googleapis.com/
http://www.google-analytics.com/
http://gg.google.com/
Run Code Online (Sandbox Code Playgroud)
您需要完全基于HTML5,并认识到这将对您的用户产生的影响.这种情况很方便,您的用户在浏览器标准/设备上是最新的,或者您可以控制用户选择.
希望这可以帮助.
小智 5
之前的答案是缓存清单功能不正确.如果您阅读http://www.w3.org/TR/html5/offline.html上的规范,在"5.7.3缓存清单语法"下,您会看到清单文件的NETWORK部分实际上列出的资源是不应缓存:
# here is a file for the online whitelist -- it isn't cached, and
# references to this file will bypass the cache, always hitting the
# network (or trying to, if the user is offline).
NETWORK:
comm.cgi
Run Code Online (Sandbox Code Playgroud)
上一张海报的例子实际上是在说:
1)缓存以下文件:
/map/mobile/examples/template.aspx
/map/mobile/examples/template.css
/map/mobile/examples/template.js
Run Code Online (Sandbox Code Playgroud)
2)从网络中获取以下内容:
http://maps.gstatic.com/
http://maps.google.com/
http://maps.googleapis.com/
http://mt0.googleapis.com/
http://mt1.googleapis.com/
http://mt2.googleapis.com/
http://mt3.googleapis.com/
http://khm0.googleapis.com/
http://khm1.googleapis.com/
http://cbk0.googleapis.com/
http://cbk1.googleapis.com/
http://www.google-analytics.com/
http://gg.google.com/
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14853 次 |
最近记录: |