将应用程序缓存与php&数据库 [英] Using appcache with php & database
问题描述
我正在使用jQuery Mobile开发Web应用程序.这些应用程序使用数据库来获取价格等(使用php). 我还使用appcache来脱机使用这些应用程序.
I'm developing web apps using jQuery Mobile. These apps use a database to get prices, etc (using php). I'm also using appcache to be able to use the apps offline.
<html manifest="manifest.appcache">
一切正常.但是当我在线时,我不希望应用程序使用应用程序缓存. 我该怎么办?
This is all working perfectly. But when I'm online, I don't want the apps to use the appcache. How do I do that?
我可以通过检查文件是否可用来检查我是否在线/离线:
I can check wether I'm online/offline by checking if a file is available:
$.ajax({
url:'http://someurl.com/online.txt',
type:'HEAD',
error: function()
{
console.log('offline');
},
success: function()
{
console.log('online');
}
});
但是我找不到页面不使用应用程序缓存的任何内容.
However I can't find anything to have the page not use the appcache..
我想念什么吗?
推荐答案
分步解决方案:
- 检查您是否在线/离线
- 如果您在线,请运行一个php脚本,该脚本会在appcache清单的末尾添加一个#.这是因为如果清单已更改,则缓存将被更新.
- 交换缓存并刷新页面
在我终于使它工作之后,我注意到由于swapCache()函数,它在Firefox中不起作用. ( https://bugzilla.mozilla.org/show_bug.cgi?id=769171) 幸运的是,我的用户没有使用Firefox.
After i finally got it working i noticed it didn't work in Firefox because of the swapCache() function. (https://bugzilla.mozilla.org/show_bug.cgi?id=769171) Lucky me my users don't use Firefox..
这篇关于将应用程序缓存与php&数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!