User:Mconnor/Pending/CookieEviction

< User:Mconnor
Revision as of 03:28, 2 September 2008 by Mconnor (talk | contribs) (User:Mconnor/CookieExpiration moved to User:Mconnor/CookieEviction: s/Expiration/eviction/)

Summary

I am proposing that we adopt a similar expiration strategy to that used by Places, which is to have a soft cap for total cookies, but expire only after cookies reach a minimum age since last use. This would mean, as it does with Places, that heavy users would store significantly more cookies, but persisting based on time rather than an arbitrary cap will better match user expectations and provide a better user experience.

Rationale

Since the change in the eviction process (using last-used time instead of last-created) people have noticed some less-used cookies frequently are expired by the time they return to the site in question. Banking and other sites that aren't accessed daily, but persist some info in cookies, are prime examples cited.

Especially with the rise of Google Analytics and other tools for tracking users, along with the different ad networks, it is easy to accept 1000 cookies in a few days of heavy browsing, which leads to older cookies being pushed out of the cookie store. This is entirely transparent to users, which leads to frustration and perceptions of dataloss.

As the current limit of 1000 cookies is relatively arbitrary, there is no harm, other than the increase in the hashtable size for cookies.

Plan

In order to leave behaviour intact for existing consumers, I propose to add a new value to network.cookie.lifetimePolicy for this new behaviour. I will add a new pref (network.cookie.minimumExpiryTime) to control the minimum number of days cookies should be retained for. When we are doing cookie evictions we will only expire cookies that are older than that number of days.

We will also move to a batched eviction setup, in order to avoid doing many eviction calls per pageload. Rather than evict one cookie each time one was added, we can start a timer similar to how cookie deletion waits and batches, and then just expire enough cookies older than N days to get down to the maximum number of cookies. If it makes sense perf-wise, if no cookies are older than 14 days, we will find the oldest cookie value and calculate when it will actually be old enough to expire, and return early until that time is reached.

For Firefox, I will also double the soft cap to 2000 cookies.