fallback when localstorage is full #1204

Closed
opened 2026-10-05 00:35:56 +02:00 by adam · 2 comments
Owner

In Piwigo 2.7 we introduced a browser-side localStorage cache for lists of tags/albums/users/groups. It works fine BUT the LocalStorage is limited in size. Once you have reached, let's say... 10k albums, then your list of albums in administration listboxes become empty and forms are broken.

The solution to manually edit the browser configuration to increase LocalStorage cache is fine as a temporary fix, but cannot be considered as valid on the long run.

The most obvious solution I see is to simply avoid LocalStorage beyond a limit of albums/tags/users/groups. It means Piwigo will have to download the full list, but it will work.

In Piwigo 2.7 we introduced a browser-side localStorage cache for lists of tags/albums/users/groups. It works fine **BUT** the LocalStorage is limited in size. Once you have reached, let's say... 10k albums, then your list of albums in administration listboxes become empty and forms are broken. The solution to manually edit the browser configuration to increase LocalStorage cache is fine as a temporary fix, but cannot be considered as valid on the long run. The most obvious solution I see is to simply avoid LocalStorage beyond a limit of albums/tags/users/groups. It means Piwigo will have to download the full list, but it will work. <!-- github-sync-id:857170638 -->
adam closed this issue 2026-10-05 00:35:56 +02:00
Author
Owner

You can also get better of both worlds by checking if localStorage is full.
Something like that :

try {
  localStorage.setItem("name", "Hello World!"); //saves to the database, "key", "value"
} catch (e) {
  if (e == QUOTA_EXCEEDED_ERR) {
    alert('Quota exceeded!'); //data wasn't successfully saved due to quota exceed so throw an error
  }
}

@see https://chrisberkhout.com/blog/localstorage-errors/

You can also get better of both worlds by checking if localStorage is full. Something like that : ```php try { localStorage.setItem("name", "Hello World!"); //saves to the database, "key", "value" } catch (e) { if (e == QUOTA_EXCEEDED_ERR) { alert('Quota exceeded!'); //data wasn't successfully saved due to quota exceed so throw an error } } ``` @see https://chrisberkhout.com/blog/localstorage-errors/ <!-- github-comment-id:818957212 -->
Author
Owner

@nikrou nice advice. It's working fine. I've made several tests with huge lists of 30k albums and the system gracefully handle the localStorage limit.

@nikrou nice advice. It's working fine. I've made several tests with huge lists of 30k albums and the system gracefully handle the localStorage limit. <!-- github-comment-id:819727166 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1204