Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Search: Index Caching Issues

Aperta
#1,593 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Refactoring
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
search

Direzione di ricerca

Leggi js/search.js, in particolare le prime quattro funzioni e le prime due che caricano e memorizzano nella cache gli indici delle lingue in localStorage. Confronta il comportamento attuale della cache per lingua con le opzioni Cache API, OPFS o cache gestita dal browser descritte nella issue; il completamento dipende dall'accordo e dall'implementazione di una strategia sostitutiva che gestisca gli indici inutilizzati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The way the search caches indexes is, in my opinion, not ideal.

Background

The current search feature caches the indexes in localStorage, using a unique key for each language.

Related code: https://github.com/php/web-php/blob/e7cfbe98203d93e00aac7c0d159d7c9c3d4faadd/js/search.js#L19 (the first 4 functions, but mostly the first 2, here deal with loading and caching the indexes)

The search indexes are ~2.1 MB (.json file size) and localStorage quota is (generally) 5MB according to https://developer.mozilla.org/en-US/docs/Web/API/Storage_API/Storage_quotas_and_eviction_criteria

The current search uses localStorage and caches the indexes with a key for each specific language.

This means that if a user uses the manual in multiple languages, they can store at most 2 before hitting the localStorage quota.

This doesn't stop search working in further languages - the indexes of further visited languages just don't get cached.

However, if a user visits a language, then never returns to it, the indexes for that language are never considered for deletion, and data in localStorage never expires otherwise (unless the user manually clears their data, or the browser decides to delete data from a site not recently visited - I don't know the specifics of browser behavior in this regard)

This means that if the user regularly uses php.net, that (old) unused data remains in localStorage forever, preventing the storage of further data. At the moment, based on a quick search of the web-php repo, this is just other search indexes, but could be used for other functionality in the future.

Alternative Options

I'm not very familiar with explicitly caching data client-side, but based on some (relatively quick) research I think that if this functionality is to be retained, it should be rewritten to use either Cache API or OPFS. These seem to be designed to do exactly what the search is using localStorage for, and the storage quotas are much larger.

An advantage of going with OPFS would be that it would be trivial to manage cached indexes for all languages (listing them in a directory) and deleting unused ones, if that's desirable.

The other alternative would be to get rid of JS caching altogether and just let the browser handle caching as with any other web request.

Does anyone else have thoughts on this?

Lingua principale
PHP
Stelle
1.1k
Fork
641
Merge medio
1g 11h
PR unite (30g)
19

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di php/web-php

Tutte le issue di php/web-php

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.