使用JQuery mobile预取和缓存未访问的页面 [英] Prefetch and cache unvisited pages with JQuery mobile

查看:97
本文介绍了使用JQuery mobile预取和缓存未访问的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个现场工程师在各种平板设备上使用的网站。一旦用户登录该站点,整个站点(所有页面,CSS,图像,javaScript文件等)必须可脱机使用。



为了方便这一点,我是使用appCache清单文件列出CACHE部分中所需的每个文件。我的理解是,这将导致浏览器缓存资源以供离线使用,但只有在浏览器首次请求这些资源时才会这样做。即单独的应用程序清单不会导致从服务器获取这些资源。



我要求用户能够登录,然后离线工作需要。理想情况下,我需要在成功登录后预取appCache清单中列出的所有资源,以便以后可以脱机使用。



成功登录后,我使用了很多来电JQuery $ .get();请求离线使用所需的每个资源。我的理解是,这将导致HTTP GET请求获取资源,并且由于缓存清单(在CACHE下列出资源),这些资源将被缓存以供离线使用。



我在这里错过了一招吗?我问的原因是我得到了意想不到的结果(离线时无法导航到未访问的页面)。



非常感谢任何帮助。 :)

I am working on a site to be used by field engineers on various tablet devices. The entire site (all pages, CSS, images, javaScript files etc) must be available offline once the user has logged into the site.

To facilitate this, I am using the appCache manifest file to list every file that will be required in the "CACHE" section. My understanding is that this will cause the browser to cache the resources for offline use, but only once those resources have been requested by the browser for the first time. i.e. the application manifest alone is not going to cause those resources to be fetched from the server.

I require the user to be able to log in, then work offline if required. I ideally need to prefetch all resources listed in the appCache manifest after successful login so that they may be used offline thereafter.

On successful login, I am using many calls to JQuery $.get(); to request every resource required for offline use. My understanding is that this will cause a HTTP GET request to fetch the resource and that because of the cache manifest (which lists the resource under "CACHE"), that those resources will be cached for offline use.

Am I missing a trick here? The reason I ask is that I'm getting unexpected results (not able to navigate to an "unvisited" page when offline).

Any assistance is much appreciated. :)

推荐答案

.get();请求离线使用所需的每个资源。我的理解是,这将导致HTTP GET请求获取资源,并且由于缓存清单(在CACHE下列出资源),这些资源将被缓存以供离线使用。



我在这里错过了一招吗?我问的原因是我得到了意想不到的结果(离线时无法导航到未访问的页面)。



非常感谢任何帮助。 :)
.get(); to request every resource required for offline use. My understanding is that this will cause a HTTP GET request to fetch the resource and that because of the cache manifest (which lists the resource under "CACHE"), that those resources will be cached for offline use.

Am I missing a trick here? The reason I ask is that I'm getting unexpected results (not able to navigate to an "unvisited" page when offline).

Any assistance is much appreciated. :)


我想出了这个。



我的预取代码正在请求Scripts / business / file1.js。



我的导航代码正在请求 s cripts /business/file1.js



我的清单文件列出了Scripts / business / file1.js



即小写字母s在导航代码,更改导航代码导致离线模式按预期工作。
I figured this one out.

My Prefetch code was requesting "Scripts/business/file1.js".

My navigation code was requesting "scripts/business/file1.js"

My manifest file was listing "Scripts/business/file1.js"

i.e. The lower case "s" in the navigation code, Changing the navigation code resulted in the offline mode working as anticipated.


这篇关于使用JQuery mobile预取和缓存未访问的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆