Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: prefetchURIForOfflineUse alternative

8 views
Skip to first unread message

Boris Zbarsky

unread,
Nov 9, 2008, 10:23:50 AM11/9/08
to
Nick Peirson wrote:
> I've tried using prefetchURI, however when navigating to the
> prefetched URI, the page still takes a few seconds to load. Using
> prefetchURIForOfflineUse, the page is cached and is displayed
> immediately.

Is this a no-store page or some other page that prefetchURI just
wouldn't cache?

> Is there an alternative method to, the now deprecated,
> prefetchURIForOfflineUse that prefetches and places a URI in the
> offline cache?

There's having an offline manifest with the page... Or perhaps using
nsIOfflineCacheUpdate directly.

> Is there any possibility of getting the method
> reinstated, as the methods it's been deprecated for,
> nsIOfflineCacheUpdateService, apply to offline applications, rather
> than caching individual URIs?

The offline cache as a whole applies to offline applications, rather
than individual URIs.

Setting followup to .network, where hopefully dcamp will see this thread.

-Boris

Nick Peirson

unread,
Nov 9, 2008, 1:46:30 PM11/9/08
to
On 9 Nov, 15:23, Boris Zbarsky <bzbar...@mit.edu> wrote:
> Nick Peirson wrote:
> > I've tried using prefetchURI, however when navigating to the
> > prefetched URI, the page still takes a few seconds to load. Using
> > prefetchURIForOfflineUse, the page is cached and is displayed
> > immediately.
>
> Is this a no-store page or some other page that prefetchURI just
> wouldn't cache?

My extension tries to prefetch the next image in a sequence, e.g. on
browsing to http://www.example.org/1.jpg it tries to prefetch and
cache http://www.example.org/2.jpg. Using prefetchURIForOfflineUse
means browsing to 2.jpg is already cached, where as with prefetchURI
it isn't and 2.jpg loads incrementally when it's browsed to. When
testing it I've checked that the http cache headers aren't stopping it
being cached, and that it's not expiring from cache immediately, so
I'm not sure why prefetchURI doesn't seem to cache the URI in the same
way that prefetchURIForOfflineUse does.

> > Is there an alternative method to, the now deprecated,
> > prefetchURIForOfflineUse that prefetches and places a URI in the
> > offline cache?
>
> There's having an offline manifest with the page... Or perhaps using
> nsIOfflineCacheUpdate directly.

As this is an extension, I'm not in control of having a manifest on
the page. nsIOfflineCacheUpdate sounds like it might do what I need,
I'll look into it.

> > Is there any possibility of getting the method
> > reinstated, as the methods it's been deprecated for,
> > nsIOfflineCacheUpdateService, apply to offline applications, rather
> > than caching individual URIs?
>
> The offline cache as a whole applies to offline applications, rather
> than individual URIs.
>
> Setting followup to .network, where hopefully dcamp will see this thread.

Thanks for the response and for directing it towards the right person.

I realise that this may not be the purpose that the offline cache was
originally intended for, however the functionality seems to be popular
with users. I've used the extension myself for a long time and having
put the extension in the AMO sandbox it's got over 100 users in a
couple of days. The prefetching aspect is the main differentiating
point from other similar addons and it would be a shame to not be able
to keep this feature when Firefox 3.1 is released.

Thanks
Nick

Boris Zbarsky

unread,
Nov 9, 2008, 8:40:28 PM11/9/08
to
Nick Peirson wrote:
> My extension tries to prefetch the next image in a sequence, e.g. on
> browsing to http://www.example.org/1.jpg it tries to prefetch and
> cache http://www.example.org/2.jpg. Using prefetchURIForOfflineUse
> means browsing to 2.jpg is already cached, where as with prefetchURI
> it isn't and 2.jpg loads incrementally when it's browsed to.

That's odd. prefetchURI should work for what you're doing here.

> When testing it I've checked that the http cache headers aren't stopping it
> being cached, and that it's not expiring from cache immediately, so
> I'm not sure why prefetchURI doesn't seem to cache the URI in the same
> way that prefetchURIForOfflineUse does.

I'd be interested in an HTTP log of this interaction.

-Boris

Boris Zbarsky

unread,
Nov 9, 2008, 8:42:19 PM11/9/08
to
Boris Zbarsky wrote:
> Nick Peirson wrote:
>> My extension tries to prefetch the next image in a sequence, e.g. on
>> browsing to http://www.example.org/1.jpg it tries to prefetch and
>> cache http://www.example.org/2.jpg. Using prefetchURIForOfflineUse
>> means browsing to 2.jpg is already cached, where as with prefetchURI
>> it isn't and 2.jpg loads incrementally when it's browsed to.
>
> That's odd. prefetchURI should work for what you're doing here.

I'd also be interested in knowing the exact values you're passing to
prefetchURI.

-Boris

Nick Peirson

unread,
Nov 10, 2008, 5:40:28 AM11/10/08
to
On 10 Nov, 01:40, Boris Zbarsky <bzbar...@mit.edu> wrote:
> I'd be interested in an HTTP log of this interaction.

I grabbed a http log from Firefox and, on browsing to the second
image, it does say:
nsHttpChannel::ReadFromCache [this=a6e0478] Using cached copy of:
http://192.168.1.4/images/2.jpg
so it looks like it's working as expected. This is the first time I've
looked into http logging from Firefox, so the previous assumption that
it wasn't caching was purely subjective. I'm going to ask the user who
reported the bug to produce a http log for me as well to check if it's
the same in their case.

Thanks for taking the time and pointing me in the right direction,
Nick

Dave Camp

unread,
Nov 10, 2008, 4:14:35 PM11/10/08
to Boris Zbarsky, dev-tech...@lists.mozilla.org
On Nov 9, 2008, at 5:40 PM, Boris Zbarsky wrote:

> Nick Peirson wrote:
>> My extension tries to prefetch the next image in a sequence, e.g. on
>> browsing to http://www.example.org/1.jpg it tries to prefetch and
>> cache http://www.example.org/2.jpg. Using prefetchURIForOfflineUse
>> means browsing to 2.jpg is already cached, where as with prefetchURI
>> it isn't and 2.jpg loads incrementally when it's browsed to.
>
> That's odd. prefetchURI should work for what you're doing here.

And the only real difference between prefetch and prefetchForOffline
in 3.0 was that prefetchForOffline would put a copy in the offline
cache, which was only checked when the browser was in the offline state.

-dave

Matej Cepl

unread,
May 23, 2011, 6:24:23 PM5/23/11
to
Dne 9.11.2008 16:23, Boris Zbarsky napsal(a):

>> Is there an alternative method to, the now deprecated,
>> prefetchURIForOfflineUse that prefetches and places a URI in the
>> offline cache?
>
> There's having an offline manifest with the page... Or perhaps using
> nsIOfflineCacheUpdate directly.

Does this method happens to be an answer to my problem as well? I am
looking for a way how to implement a fix for
https://bugzilla.mozilla.org/655749, i.e. how to put programatically a
resource to the offline application cache
(https://developer.mozilla.org/en/Offline_resources_in_Firefox).

My extension (Jetpack-based)
https://fedorahosted.org/bugzilla-triage-scripts/ has all its business
logic (so to say) in a JSON file which could be downloaded from anywhere
users puts it. However, during the recent outage of (otherwise very
reliable) server fedorapeople.org I was rudely reminded that there is no
such thing as a 100% reliable server, so I would prefer if my users
would have the configuration file cached and only updated when
necessary, and when the server is down (or whole internet connection ...
I am also playing with the idea of making whole extension working with
Bugzilla offline, and posting the results only when online), then user
would have still working system.

I started to write my own simple cache (like in http://is.gd/Tasdyd )
but it seems to be silly not to use what's already in Firefox if it is
at least accessible to the Javascript add-on. The only thing I found
which seemed to be pointing in the right direction is but is a bug
https://bugzilla.mozilla.org/367447 but it seems to be based on <link
rel="offline-resource"> which status seems to be quite foggy as well.

Could you point me to some example of doing this (C++ or Javascript are
both fine with me), please?

Thank you,

Matěj

0 new messages