How do I set max browsing history size?

How do I set how many URLs (maximum) can be stored in the browsing history of Firefox?

I don't see such an option in the settings dialog.


Solution 1:

NOTE: I'm using Firefox 40.0.3 here.

I believe the relevant option is places.history.expiration.max_pages. It doesn't exist by default, so you'll have to go to about:config and create it.

Once you create it and set it, check the value of places.history.expiration.transient_current_max_pages — it should automatically adjust itself to match your .max_pages setting. If this is the case, it means you've set .max_pages correctly.

Results:

(Now on Firefox 52.0.2)

It's 2017 and since I wrote this answer I don't seem to have lost any history. My oldest history entries (from 2013) are still there. I have well over 100,000 pages in history and my "places.sqlite" is 71 MB.

Technical details:

The relevant function is PEX__loadPrefs() in nsPlacesExpiration.js. It tries to determine the limit by first checking PREF_MAX_URIS (which is "max_pages"). If PREF_MAX_URIS isn't set or is a negative value, it then attempts to calculate the 'optimal database size' based on available memory and disc space. So, it appears that setting places.history.expiration.max_pages overrides all this logic.

If you want it to retain all history ('infinite' history) you could try setting max_pages to 2147483647 (the highest 32-bit signed integer). I haven't actually tested this myself, but the database would probably be crushed under its own weight before reaching this limit.