Preserve Cache

118 views
Skip to first unread message

Nilesh Govindarajan

unread,
May 26, 2010, 5:09:22 AM5/26/10
to
I am using Firefox on Arch Linux. My connection is a bit slow, so the
cache is very precious to me. But if Firefox crashes or I have to
issue an SIGTERM to it due to unavoidable circumstances, I lose my
cache of so many megabytes. What should I do to preserve that loss if
not by keeping a backup copy of the cache ?

Fox on the run

unread,
May 26, 2010, 5:48:35 AM5/26/10
to

The default is to keep the cache (with a fixed limit of disk space
allocated for that purpose). Stuff gets cached as you surf. So even
with a crash, it should still be all there. Did you set your privacy
settings perhaps to clear your browser history on exit? Or do you
sometimes manually clear it via th menu option?

JB

Nilesh Govindarajan

unread,
May 27, 2010, 8:42:49 AM5/27/10
to

Nope neither. I told you that cache is very precious to me. I am not
so dumb to do that lol. If I use the clear option then I don't clear
the cache, but cookies, history and others.
I know that is the default, but all sites open slower when it crashes
and I start it next time. Also the disk usage reduces which is clear
indication that the cache is getting cleared. I had some 200-300 MB of
cache, all lost :(

Fox on the run

unread,
May 27, 2010, 1:07:11 PM5/27/10
to

I learn something every day. Did a google search for Firefox clear
cache on crash and found a few good hits including this one:

http://abhi247.com/myblog/2009/06/30/manually-solve-empty-cache-after-crash-problem-in-firefox/

Seems Firefox sets a dirty bit in the cache file. If the browser
crashes, the dirty bit remains and next time Firefox starts, it clears
its cache to avoid corrupt data. The a/n URL provides a way to
manually flip that dirty bit with a hex editor should FF crash on you.

JB

Fox on the run

unread,
May 27, 2010, 1:28:04 PM5/27/10
to
On May 27, 3:07 pm, Fox on the run <jjrbouc...@gmail.com> wrote:

>
> I learn something every day.  Did a google search for Firefox clear
> cache on crash and found a few good hits including this one:
>

> http://abhi247.com/myblog/2009/06/30/manually-solve-empty-cache-after...


>
> Seems Firefox sets a dirty bit in the cache file.  If the browser
> crashes, the dirty bit remains and next time Firefox starts, it clears
> its cache to avoid corrupt data.  The a/n URL provides a way to
> manually flip that dirty bit with a hex editor should FF crash on you.
>
> JB

Further to my last message I tested this. With FF running the 16th
byte (so skip 15) was indeed \x01. On clean shutdown it became \x00.
Restarted FF, back to \x01. Forced a crash by killing the process
and that byte remained \x01. Restarted FF and sure enough, all my
cache disappeared (folder completely empty - cache file returning
after I surfed a few pages and exited the browser again).

So your solution would be either rsync that folder prior to starting
FF (perhaps start FF from a bash script that does the rsync first).
If FF crashes, delete the cache and rsync the backup back to the
original location. Or alternatively if FF crashes go manually flip
that bit (but there is a risk of corruption whereas the other solution
will not cause potential corruption seeing you are restoring a version
of cache from a clean shutdown of FF).

JB

Nilesh Govindarajan

unread,
May 27, 2010, 1:42:44 PM5/27/10
to

Thanks a lot for that. I tried the bash script method, but that isn't
good because it then breaks the default URL handlers in other
applications. I had even written a tutorial on that on my site. But
after getting fed up myself having to copy-paste every URL I get in
chat, I reverted back to launching from /usr/bin.
I'll add a tar command in my login script. That would be best I think.

g

unread,
May 27, 2010, 6:29:44 PM5/27/10
to firefox-support
Nilesh Govindarajan wrote:
> On May 27, 10:28 pm, Fox on the run <jjrbouc...@gmail.com> wrote:
>> On May 27, 3:07 pm, Fox on the run <jjrbouc...@gmail.com> wrote:

<snip>

> Thanks a lot for that. I tried the bash script method, but that isn't
> good because it then breaks the default URL handlers in other
> applications. I had even written a tutorial on that on my site. But
> after getting fed up myself having to copy-paste every URL I get in
> chat, I reverted back to launching from /usr/bin.
> I'll add a tar command in my login script. That would be best I think.

this is all well and good. but there is an easier way.

+++
'edit > preferences > privacy'
---
private data

[x] always clear my private data when i close firefox
[x] ask me before clearing private data
+++

granted, you will be prompted every time you close firefox, but you have
ability to _set_ what you want _cleared_ and when you close firefox you
have choice to clear what you want cleared or not.

plus, when you restart from a crash, you are prompted to clear or not.

a lot easier than using a hex editor or a script. try it. you will see
how easy it is and why firefox authors put 'dirty bit' and feature in.

--

peace out.

tc,hago.

g
.

****
in a free world without fences, who needs gates.
**
help microsoft stamp out piracy - give linux to a friend today.
**
to mess up a linux box, you need to work at it.
to mess up an ms windows box, you just need to *look* at it.
**
learn linux:
'Rute User's Tutorial and Exposition' http://rute.2038bug.com/index.html
'The Linux Documentation Project' http://www.tldp.org/
'LDP HOWTO-index' http://www.tldp.org/HOWTO/HOWTO-INDEX/index.html
'HowtoForge' http://howtoforge.com/
****

signature.asc

Fox on the run

unread,
May 27, 2010, 8:06:58 PM5/27/10
to
On May 27, 8:29 pm, g <gel...@bellsouth.net> wrote:
>
> this is all well and good. but there is an easier way.
>
> +++
> 'edit > preferences > privacy'
> ---
> private data
>
>  [x] always clear my private data when i close firefox
>  [x] ask me before clearing private data
> +++
>
> granted, you will be prompted every time you close firefox, but you have
> ability to _set_ what you want _cleared_ and when you close firefox you
> have choice to clear what you want cleared or not.
>
> plus, when you restart from a crash, you are prompted to clear or not.
>
> a lot easier than using a hex editor or a script. try it. you will see
> how easy it is and why firefox authors put 'dirty bit' and feature in.
>
> --
>
> peace out.
>
> tc,hago.
>
> g
> .
I don't see that option in FF 3.6 (to prompt to clear your privacy
settings). I added the boolean value
privacy.sanitize.promptOnSanitize which previously controlled that
however it still didn't prompt me. So clearly that option is
obsolete.

JB

Fox on the run

unread,
May 27, 2010, 8:34:13 PM5/27/10
to

If you want to flip that bit (living a bit on the dangerous side given
the risk of data corruption the the Cache) you could use the following
dd command (executed from the folder where cache is located so you
could adapt it to run from your home folder via a bash file). If you
have a backup in addition to this, then you could take the chance. If
you are a real risk taker you could run that automatically when you
open your shell. if it's already \x00, nothing will change as the
same value gets written to it. If it was \x01 for a crash, it gets
changed.

echo -e "\x00" | dd of=_CACHE_MAP_ bs=1 seek=15 count=1 conv=notrunc

JB

Fox on the run

unread,
May 27, 2010, 8:41:27 PM5/27/10
to

Just tested it in the reverse (clean exit of FF, flipped it to \x01,
restarted FF) and as expected it cleared the cache.

JB

Nilesh Govindarajan

unread,
May 28, 2010, 12:06:23 AM5/28/10
to
>  signature.asc
> < 1KViewDownload

Dude I want to preserve the cache and you're talking about clearing
it !

Nilesh Govindarajan

unread,
May 28, 2010, 12:07:08 AM5/28/10
to

Thanks.

Tarkus

unread,
May 28, 2010, 12:32:23 AM5/28/10
to
On 5/27/2010 10:07 AM, Fox on the run wrote:
> I learn something every day. Did a google search for Firefox clear
> cache on crash and found a few good hits including this one:
>
> http://abhi247.com/myblog/2009/06/30/manually-solve-empty-cache-after-crash-problem-in-firefox/
>
> Seems Firefox sets a dirty bit in the cache file. If the browser
> crashes, the dirty bit remains and next time Firefox starts, it clears
> its cache to avoid corrupt data. The a/n URL provides a way to
> manually flip that dirty bit with a hex editor should FF crash on you.

Maybe now people will get that this is not an illusion.

Nilesh Govindarajan

unread,
May 28, 2010, 4:24:04 AM5/28/10
to
On May 28, 9:32 am, Tarkus <karnev...@atlantabraves.net> wrote:
> On 5/27/2010 10:07 AM, Fox on the run wrote:
>
> > I learn something every day.  Did a google search for Firefox clear
> > cache on crash and found a few good hits including this one:
>
> >http://abhi247.com/myblog/2009/06/30/manually-solve-empty-cache-after...

>
> > Seems Firefox sets a dirty bit in the cache file.  If the browser
> > crashes, the dirty bit remains and next time Firefox starts, it clears
> > its cache to avoid corrupt data.  The a/n URL provides a way to
> > manually flip that dirty bit with a hex editor should FF crash on you.
>
> Maybe now people will get that this is not an illusion.

Yeah true. For those on slow connections like me, cache is very
precious, so backup is very important. Or install some local caching
proxy like squid :D

Fox on the run

unread,
May 28, 2010, 6:05:08 AM5/28/10
to
On May 28, 2:06 am, Nilesh Govindarajan <li...@itech7.com> wrote:
> On May 28, 3:29 am, g <gel...@bellsouth.net> wrote:
<snip>

It sounds like that, but what he was suggesting (and it might work if
the preference still existed) is to set the option to clear all your
private data on exit but then to prompt you before doing it. This way
you would opt to not clear it (or only clear what you want). The
reason for this would that in the event of a crash, FF would abide by
the preference to always prompt you before clearing your private
data. So on the reboot the expected behaviour would be that FF would
see the crash, go to clear your cache but then would abide by the
preference to prompt you before clearing private data at which time
you could opt to not clear it.

So the suggestion was a potentially viable solution as I do know that
preference to prompt before clearing private data existed in the past
(but not sure if it would be respected on a restart from a crash so I
tried to test it and realized that not only is that preference absent
from the menu, it is ignored even if you add it via about:config.

JB

Tarkus

unread,
May 28, 2010, 11:50:05 AM5/28/10
to

When I was on dialup, it was painfully obvious. Even on a mobile
connection, it can be noticeable. Thankfully, I rarely get crashes from
either Windows 7 or Firefox these days, so it's not much of an issue.
FF used to crash quite regularly on me.

Nilesh Govindarajan

unread,
May 28, 2010, 12:25:01 PM5/28/10
to

Doesn't happen with me much either. Its mostly I have to force-quit
firefox because some other process started hogging memory and cpu like
anything that too on a dual core.

g

unread,
May 29, 2010, 1:48:24 PM5/29/10
to firefox-support
Fox on the run wrote:
<snip>

> So the suggestion was a potentially viable solution as I do know that
> preference to prompt before clearing private data existed in the past
> (but not sure if it would be respected on a restart from a crash so I
> tried to test it and realized that not only is that preference absent
> from the menu, it is ignored even if you add it via about:config.

starting/restarting firefox from a crash or os shutdown without closing
firefox cause prompt, same as if firefox is shutdown normally.

signature.asc

g

unread,
May 29, 2010, 1:42:30 PM5/29/10
to firefox-support
Fox on the run wrote:
<snip>

> I don't see that option in FF 3.6 (to prompt to clear your privacy


> settings). I added the boolean value
> privacy.sanitize.promptOnSanitize which previously controlled that
> however it still didn't prompt me. So clearly that option is
> obsolete.

i am still using 3.0.19 and enjoying it because i have seen post of
where too much has been dropped in upgrading to 3.6.

it is still listed on these pages;

http://kb.mozillazine.org/About:config_entries
http://kb.mozillazine.org/Firefox_:_FAQs_:_About:config_Entries


you might check http://preferential.mozdev.org/ to see if it is
available thru 'preferential' extension.

maybe you should write it up as a bug to see if it gets added in
next update/grade.

for sure, it is one hell of a good feature.


--

peace out.

tc,hago.

g
.

****

signature.asc

Fox on the run

unread,
May 29, 2010, 3:01:40 PM5/29/10
to
>  signature.asc
> < 1KViewDownload

Good point. I flipped the bit in cache, however I didn't go and
change the state in sessionstore.js to running in order to fool
Firefox to think it was a browser crash. I only half fooled it when I
flipped the bit. So my testing of manually adding that preference was
flawed as it didn't accurately replicate a crash. But the fact that
it indiscriminately deleted the cache when it saw the dirty bit on
restart still leads me to suspect that even if I had properly
replicated a crash by changing the state in sessionstore.js to running
the results would have been the same. But I can't say that for
certain so will have to test it if I get a chance.

JB

g

unread,
May 29, 2010, 5:04:12 PM5/29/10
to firefox-support
Fox on the run wrote:
<snip>

>> starting/restarting firefox from a crash or os shutdown without closing

>> firefox cause prompt, same as if firefox is shutdown normally.

> Good point. I flipped the bit in cache, however I didn't go and change the


> state in sessionstore.js to running in order to fool Firefox to think it
> was a browser crash.

<snip>


> But I can't say that for certain so will have to test it if I get a chance.

shutting down system with firefox still open should bring same effect
as a crash and it is quicker than flipping a bit or messing with files.

i believe that all of the safety is for firefox not closing properly,
and ability to open clean if desired. be it crash or left open and
system shut down.

signature.asc

Fox on the run

unread,
May 29, 2010, 8:37:13 PM5/29/10
to
>  signature.asc
> < 1KViewDownload

Just re-tested where I manually added the about:config entry to prompt
before clearing privacy settings, as well as from the GUI setting the
option to sanitize on shutdown. I exited the browser but was never
prompted to confirm that I wanted to clear those privacy settings. So
clearly that setting is no longer in effect. Perhaps the feature was
not used frequently enough. But then again if it was already coded,
why remove it unless it was creating a potential conflict with
something else. Makes little sense to remove flexible behaviour
unless it breaks something else that is used more frequently.

I then tested it by crashing Firefox while having the option to clear
settings on exit, and the about:config preference added to prompt
before clearing. So everything at that point is replicated properly.
Firefox crashed with the preferences set to clear private data, but
prompt first. Cache still existed at that point as did the other info
(history, form info, etc). Restarted Firefox. It restored the tabs
from the session that had just crashed, but still went and cleared the
private settings including cache. So definitely a preference that was
removed sometime between 3.0.x and 3.6.x

It is not a setting I personally used so I won't bother filing a bug
report. As to why it was removed, I can only assume it was done for a
reason as I hypothesized above.

JB

g

unread,
May 30, 2010, 1:16:27 AM5/30/10
to firefox-support
Fox on the run wrote:
<snip>

> Just re-tested where I manually added the about:config entry to prompt
<snip>


> So definitely a preference that was removed sometime between 3.0.x and
> 3.6.x

bummer.

> It is not a setting I personally used so I won't bother filing a bug
> report.

i wish you would. then when i get to 3.6 or later version, it will have been
corrected. :)

> As to why it was removed, I can only assume it was done for a reason as I
> hypothesized above.

infinite ?wisdom? of authors.

how in hell do they know what others do and do not use?

personally, from my own experience, it is a true 'butt saver'.

signature.asc

The Real Bev

unread,
May 31, 2010, 9:05:46 PM5/31/10
to
On 05/27/10 05:42, Nilesh Govindarajan wrote:

> On May 26, 2:48 pm, Fox on the run<jjrbouc...@gmail.com> wrote:
>> On May 26, 7:09 am, Nilesh Govindarajan<nil...@itech7.com> wrote:
>>
>> > I am using Firefox on Arch Linux. My connection is a bit slow, so the
>> > cache is very precious to me. But if Firefox crashes or I have to
>> > issue an SIGTERM to it due to unavoidable circumstances, I lose my
>> > cache of so many megabytes. What should I do to preserve that loss if
>> > not by keeping a backup copy of the cache ?
>>
>> The default is to keep the cache (with a fixed limit of disk space
>> allocated for that purpose). Stuff gets cached as you surf. So even
>> with a crash, it should still be all there. Did you set your privacy
>> settings perhaps to clear your browser history on exit? Or do you
>> sometimes manually clear it via th menu option?
>

> Nope neither. I told you that cache is very precious to me. I am not
> so dumb to do that lol. If I use the clear option then I don't clear
> the cache, but cookies, history and others.
> I know that is the default, but all sites open slower when it crashes
> and I start it next time. Also the disk usage reduces which is clear
> indication that the cache is getting cleared. I had some 200-300 MB of
> cache, all lost :(

My cache too is precious to me -- "What was that website that I looked at a
couple of months ago that had 'teakettles' in it?" An extension called
CacheViewer is very useful.

I just updated to FF 3.6.3 this morning. Not only did several of the
tab-manipulation extensions stop working properly, my cache was entirely wiped
out. I've got 38 meg today, but I probably had at least a gig before. Next
time I have to do an update I'm going to copy the entire subdirectory somewhere
else just in case.

Sometimes when websites don't work right, the instruction is given to clear the
cache. Damn presumptuous if you ask me. Why should *I* have to throw away
something I want to keep just because they don't know how to do something?

I'm getting to hate doing FF and TB updates. SOMETHING that was important to
me always gets trashed and I have to try to fix it. Sometimes I can't. Damn
nuisance.

Right now I'm really ticked about the TB3 vertical view -- I can't put the
message pane in the middle, although I could with TB2 by adding the following
magic words to userChrome.css:

messagesBox {-moz-box-direction: reverse;}

Doesn't work now. Feh.

--
Cheers, Bev
--------------------------------------------
There is no such thing as a foolproof device
because fools are so ingenious.

Nilesh Govindarajan

unread,
Jun 1, 2010, 1:48:34 AM6/1/10
to
On Jun 1, 6:05 am, The Real Bev <bashley101+...@gmail.com> wrote:
> On 05/27/10 05:42, Nilesh Govindarajan wrote:
>
>
>
> > On May 26, 2:48 pm, Fox on the run<jjrbouc...@gmail.com>  wrote:
> >>  On May 26, 7:09 am, Nilesh Govindarajan<nil...@itech7.com>  wrote:
>
> >>  >  I am using Firefox on Arch Linux. My connection is a bit slow, so the
> >>  >  cacheis very precious to me. But if Firefox crashes or I have to

> >>  >  issue an SIGTERM to it due to unavoidable circumstances, I lose my
> >>  >  cacheof so many megabytes. What should I do topreservethat loss if

> >>  >  not by keeping a backup copy of thecache?
>
> >>  The default is to keep thecache(with a fixed limit of disk space

> >>  allocated for that purpose).  Stuff gets cached as you surf.  So even
> >>  with a crash, it should still be all there.  Did you set your privacy
> >>  settings perhaps to clear your browser history on exit?  Or do you
> >>  sometimes manually clear it via th menu option?
>
> > Nope neither. I told you thatcacheis very precious to me. I am not

> > so dumb to do that lol. If I use the clear option then I don't clear
> > thecache, but cookies, history and others.

> > I know that is the default, but all sites open slower when it crashes
> > and I start it next time. Also the disk usage reduces which is clear
> > indication that thecacheis getting cleared. I had some 200-300 MB of
> >cache, all lost :(
>
> Mycachetoo is precious to me -- "What was that website that I looked at a

> couple of months ago that had 'teakettles' in it?"  An extension called
> CacheViewer is very useful.
>
> I just updated to FF 3.6.3 this morning.  Not only did several of the
> tab-manipulation extensions stop working properly, mycachewas entirely wiped

> out.  I've got 38 meg today, but I probably had at least a gig before.  Next
> time I have to do an update I'm going to copy the entire subdirectory somewhere
> else just in case.
>
> Sometimes when websites don't work right, the instruction is given to clear thecache.  Damn presumptuous if you ask me.  Why should *I* have to throw away

> something I want to keep just because they don't know how to do something?
>
> I'm getting to hate doing FF and TB updates.  SOMETHING that was important to
> me always gets trashed and I have to try to fix it.  Sometimes I can't.  Damn
> nuisance.
>
> Right now I'm really ticked about the TB3 vertical view -- I can't put the
> message pane in the middle, although I could with TB2 by adding the following
> magic words to userChrome.css:
>
> messagesBox {-moz-box-direction: reverse;}
>
> Doesn't work now.  Feh.
>
> --
> Cheers, Bev
> --------------------------------------------
> There is no such thing as a foolproof device
> because fools are so ingenious.

Duh, I have stopped relying now on Firefox for cache. I am using my
local apache installation which I normally use to test and develop web
applications as a caching proxy server. Life is much better now. It
has already made around 70 MB of cache :) :) :)

Reply all
Reply to author
Forward
0 new messages