“添加到主屏幕”中的 HTML5 缓存清单移动网络应用程序似乎不起作用

发布于 2024-10-31 19:24:05 字数 1255 浏览 1 评论 0原文

我正在开发一个移动 Web 应用程序,该应用程序连接到在线数据库,从该数据库加载数据到离线本地 mysqlite 数据库中,然后应该可以离线使用。 我让整个数据库工作正常,但该应用程序仍然无法离线使用,因为它没有正确缓存所有资源。

我的清单如下所示:

CACHE MANIFEST
# Cache manifest version 0.0.5

http://www.mywebsite.com/appfolder/app/detail.html
http://www.mywebsite.com/appfolder/app/index.html
http://www.mywebsite.com/appfolder/app/list.html
http://www.mywebsite.com/appfolder/css/style.css
http://www.mywebsite.com/appfolder/src/iscroll.js
http://www.mywebsite.com/appfolder/js/jquery-1.5.1.min.js
http://www.mywebsite.com/appfolder/thumbs/1872A.jpg
http://www.mywebsite.com/appfolder/thumbs/1913.jpg
http://www.mywebsite.com/appfolder/thumbs/1916.jpg
http://www.mywebsite.com/appfolder/thumbs/1925.jpg
http://www.mywebsite.com/appfolder/carsimages/1872A_1.jpg
http://www.mywebsite.com/appfolder/carsimages/1872A_2.jpg

NETWORK:

# All URLs that start with the following lines
# are whitelisted.

CACHE:

# Additional items to cache.

FALLBACK:

该应用程序在线时运行顺利,但一旦我离线,我会收到以下错误消息:“Myappname 无法打开,因为它未连接到互联网”(在“添加到主屏幕”中 - 在iPad) 和 “Safari 无法打开该页面,因为它未连接到互联网”(在同一台 iPad 上的 Safari 视图中)

我已经采取的步骤: 通过将其添加到我的 .htaccess 文件中,确保清单由正确的内容类型提供服务您

AddType text/cache-manifest .manifest

知道为什么这不起作用吗?

Im' working on a mobile webapp that connects to an online database, loads data from that database in an offline local mysqlite database, and should then be available offline.
I got the whole database stuff working, but the app is still not available offline because it does not cache all resources correctly.

My manifest looks like this:

CACHE MANIFEST
# Cache manifest version 0.0.5

http://www.mywebsite.com/appfolder/app/detail.html
http://www.mywebsite.com/appfolder/app/index.html
http://www.mywebsite.com/appfolder/app/list.html
http://www.mywebsite.com/appfolder/css/style.css
http://www.mywebsite.com/appfolder/src/iscroll.js
http://www.mywebsite.com/appfolder/js/jquery-1.5.1.min.js
http://www.mywebsite.com/appfolder/thumbs/1872A.jpg
http://www.mywebsite.com/appfolder/thumbs/1913.jpg
http://www.mywebsite.com/appfolder/thumbs/1916.jpg
http://www.mywebsite.com/appfolder/thumbs/1925.jpg
http://www.mywebsite.com/appfolder/carsimages/1872A_1.jpg
http://www.mywebsite.com/appfolder/carsimages/1872A_2.jpg

NETWORK:

# All URLs that start with the following lines
# are whitelisted.

CACHE:

# Additional items to cache.

FALLBACK:

The app runs smooth while online, but once I go offline I get these error messages: "Myappname could not be opened because it is not connected to the internet" (in "added to homescreen"-view on an iPad)
and
"Safari cannot open the page because it is not connected to the internet" (in safari-view on that same iPad)

Steps I already took:
Made sure the manifest got served by the correct content type by adding this to my .htaccess file

AddType text/cache-manifest .manifest

Any ideas why this does not work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

极度宠爱 2024-11-07 19:24:05

对于 iPad,缓存清单文件必须命名为“cache.manifest”。这为我解决了这个问题。

For the iPad, the cache manifest file MUST BE named as "cache.manifest". This fixed the issue for me.

沫离伤花 2024-11-07 19:24:05

如果您要连接到在线资源,我希望在“网络”部分中看到该资源的 URL。应用程序访问的每个 URL 都需要显式或隐式地在清单中列出。

尝试添加:

NETWORK:
*

指示在线时可能会访问任何 URL。

If you are connecting to an online resource, I would expect to see the URL to that resource in the NETWORK section. Every URL accessed by the application needs to be listed in the manifest either explicitly or implicitly.

Try adding:

NETWORK:
*

To indicate that any URL might potentially be accessed while online.

赠佳期 2024-11-07 19:24:05

资源必须位于 CACHE 部分下。请参阅http://www.html5rocks.com/en/tutorials/appcache/beginner/< /a>

The resources must be under the CACHE section. See http://www.html5rocks.com/en/tutorials/appcache/beginner/

最美的太阳 2024-11-07 19:24:05

我很好奇莉兹·达利的回答。我正在使用 iPad,我刚刚(遗憾地)从 iOS 4.2 更新到了 iOS 4.3。我有一个运行良好的 HTML5 离线应用程序,它可以从主屏幕运行,无需互联网连接,并且能够将状态保存到 localStorage 存储中。

在我将 iPad 更新到 iOS 4.3 后,如果每次我从主屏幕启动它时没有互联网连接来重新加载页面,这个应用程序现在就无法工作,而且当我关闭 iPad 电源时,localStorage 也会被清除。

因此,我在 iPad 上的 iOS 4.3 上运行我的离线应用程序时,Safari 遇到了真正的问题,并且 Apple 没有透露何时或是否会解决此问题(至少将其恢复到 iOS 4.2 中的相同功能) 。

I am curious about Liz Daly's answer. I am using an iPad which I just (regrettably) updated to iOS 4.3 from iOS 4.2. I had an HTML5 offline app working fine which can run from Home Screen without needing an Internet connection and be able to save state into the localStorage store.

After I updated my iPad to iOS 4.3, this very app now does NOT work without having an Internet connection to reload the page each time I start it from the Home screen and also, the localStorage gets wiped out when I power off the iPad.

So, I am having REAL problems with Safari running my offline app on iOS 4.3 on my iPad and there is no news from Apple when or if they are going to fix this issue (at least restore it back to the same functionality in iOS 4.2).

转角预定愛 2024-11-07 19:24:05

更新到我之前的帖子。我现在可以在 iPad 上运行 HTML5 离线应用程序。首先,我相信您需要将 iPad 至少更新到 4.3.2(未经证实,但我现在使用的是 4.3.3)。更重要的是,缓存清单文件必须命名为“cache.manifest”。在我的实验中,如果您使用任何其他名称,那么它将无法离线运行。我在全屏模式下离线运行(即将“apple-mobile-web-app-capable”设置为“yes”),它将在航空模式下从主屏幕运行。

所以莉兹·达利是部分正确的。离线模式似乎仅在上述限制下才有效。

Update to my previous post. I can now run my HTML5 offline app on my iPad. First I believe you will need to update the iPad to at least 4.3.2 (unconfirmed but I am using 4.3.3 now). And more importantly, the cache manifest file MUST BE named as "cache.manifest". In my experiments, if you use any other name, then it will not run offline. I have my offline running in full screen mode (i.e. set "apple-mobile-web-app-capable" to "yes") and it will run from the Home Screen in Airline mode.

So Liz Daly is partially correct. The offline mode seems to only work under the above constraints only.

旧城烟雨 2024-11-07 19:24:05

我在 iPad 上也遇到了同样的问题。事实证明,它不喜欢在文件夹中缓存清单文件。我有 /Content/cache.manifest 并且它不起作用(离线时该应用程序不会从主屏幕加载)。当我将清单文件移至应用程序根目录并将清单引用更改为 cache.manifest 时,它开始工作。

(它不必被称为cache.manifest - 我让它与CacheManifest.ashx一起使用)

I had the same issue on iPad. Turns out that it does not like cache manifest files in a folder. I had /Content/cache.manifest and it did not work (the app wouldn't load from the home screen when offline). When i moved the manifest file to the app root and changed manifest reference to cache.manifest it started working.

(It does not have to be called cache.manifest - i have it working with CacheManifest.ashx)

北方。的韩爷 2024-11-07 19:24:05

据我了解,在 iOS 4.3 中,HTML 5“离线网络应用程序”功能已损坏:

http://www.theregister.co.uk/2011/03/15/apple_ios_throttles_web_apps_on_home_screen/

此外,此类“主屏幕网络应用程序”无法使用各种网络缓存系统,包括 HTML5 应用程序缓存,这意味着它们无法缓存以离线运行。

另请参阅:
离线 iOS Web 应用程序:加载我的清单,但是无法离线工作

I understand that in iOS 4.3 the HTML 5 "offline web app" function is broken:

http://www.theregister.co.uk/2011/03/15/apple_ios_throttles_web_apps_on_home_screen/

What's more, such "home screen web apps" can't use various web caching systems, including the HTML5 Application Cache, which means they can't be cached to run offline.

Also see:
Offline iOS web app: loads my manifest, but doesn't work offline

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文