Martin Baehr wrote (previous subject was: Wish list):
>
> On Wed, Sep 11, 2002 at 02:24:09AM +0200, Paul A. Rombouts wrote:
> > Martin Baehr wrote:
> > > don't delete old files if a refresh returns a 404.
> > There is the question though what to send to the browser while wwwoffle is
> > online. Should the page containing the 404 response code be sent or the
> > contents of the old spool file?
> 
> i think it should always be the errormessage that is sent to the user,
> unless the user asks otherwise.
> 
> in offline mode a reload of the page could allow to get to the old page.
> just like wwwoffle-errors:
>    Reloading this page will revert to the previous version if you are offline
>    or try again if you are online.
> 404 could be treated the same way.

OK, this essentially what I've tried to implement.
I've added an option to the OnlineOptions section that I called
"keep-cache-if-not-found" (I'm open to suggestions for a better name).
While you're online, if this option is enabled for a certain URL, and the remote
server returns a status code >=300, and there is a previously cached version for
this URL with status code 200, my modified version of WWWOFFLE will write a
warning message to the cache and keep the previously cached page as a backup.
The browser will receive the content from the remote server, so while you're
online you should not notice anything different from what you're used to.
Only when you go offline and request the same URL, will you see the WWWOFFLE
warning message.
After reloading the same page (while you're still offline) you should see the
old preserved content.

You will notice that this new feature is triggered by all possible redirection
and error responses from the remote server and not just the 404 code. This is
because I've noticed that web servers will nowadays often redirect to a search
page instead of giving a 404 response. And if you really want to preserve a
page, it makes sense to me to protect it from being overwritten by any possible
error response, not just 404.
If the previously cached page already had a redirection or error code, the new
feature will not take effect, and the old cache file will be overwritten just as
it used to happen.


> in online mode maybe the same could be done,
> returning the old page if the browser asked for a refresh
> and the server content has not changed since.
> 
> otherwise some special url (through localhost)
> might be necessary to access the old page.
> (which would be more work to implement,
> but then it would also help towards mierniks suggestion
> of generally keeping a backup of the previous page
> for wich the above reload method makes no sense.)

My present implementation will always show you fresh content from the remote
server while you're online, it's not (yet) possible to see the old page until
you go offline.
This is the simplest solution that I could think of that still would be useful
(and hopefully not too confusing).
I think it's best to experiment with this solution before trying something
more complicated.

In case you want to try it out for yourself, I've made two patch files
available.
The first one is a big one containing all the modifications I've ever made to
WWWOFFLE. This is the version I'm using myself. It can be downloaded from

  http://www.phys.uu.nl/~rombouts/wwwoffle-2.7f-par-2.diff.gz

The second patch file is much smaller and contains only changes necessary to
implement the new feature. I've not tested this version myself, all I know is
that it compiles. It can be downloaded from

  http://www.phys.uu.nl/~rombouts/wwwoffle-2.7f-preserve_cache_patch.gz

I've also made a page containing instructions on how to use these patches:

  http://www.phys.uu.nl/~rombouts/wwwoffle_patches.html


Good luck, and let me know if you find this feature useful.

-- 
Paul A. Rombouts <[EMAIL PROTECTED]>

My alternative WWWOFFLE implementation page:
  http://www.phys.uu.nl/~rombouts/wwwoffle.html

Reply via email to