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

Document Cache-Control on stored files and imagine variants (bundle #414)

Chiusa Adatta ai principianti
#212 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
aws, bash, php, yaml
Ambito
documentation

Direzione di ricerca

Inizia dalla pagina dei caricamenti dell’API in content/4.api/ e controlla come è organizzata la documentazione esistente sulla configurazione e sui caricamenti. Aggiungi la configurazione Cache-Control, le sostituzioni per campo, il comportamento dell’adapter, i comandi di backfill e la nota su Cloud CDN dell’issue. Il lavoro sarà completato quando la pagina documenterà questi dettagli e gli esempi avranno una formattazione coerente con i contenuti circostanti.

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

Descrizione

Bundle PR: https://github.com/components-web-app/api-components-bundle/pull/415 (issue components-web-app/api-components-bundle#414)

Please document the following on the API uploads page (content/4.api/).

Configuration

silverback_api_components:
  uploadable:
    cache_control:
      original: 'public, max-age=31536000, immutable'   # uploads (default)
      imagine: 'public, max-age=2592000'                # imagine variants (default)
  • null writes no Cache-Control.
  • The defaults are safe because stored names are tokenised (<slug>-<8 hex>.<ext>), so a new upload never reuses a path. A variant is written again at the same path only when its filter is regenerated, which is why it gets 30 days and not immutable. After regenerating a filter, a browser can keep a stale variant for up to 30 days. Renaming the filter gives the variants new URLs (see #413).

Per-field override

#[Silverback\UploadableField(adapter: 'gcloud', cacheControl: 'private, max-age=60', imagineCacheControl: false)]
  • cacheControl: applies to the uploaded file and imagineCacheControl: to its variants.
  • Leaving either unset (null) uses the bundle config. false writes none, even when the bundle config sets one.

Adapter support

  • Only Google Cloud Storage (metadata.cacheControl, beside contentType) and S3 (CacheControl, for both the AWS SDK and AsyncAws adapters) receive it. Other adapters ignore it; a local adapter's headers come from its web server.
  • It is written only through filesystems the bundle builds from the silverback.api_components.filesystem_adapter tag (api_components.filesystem.<alias>). A FlysystemCacheResolver should therefore be given @api_components.filesystem.<alias>, as the template does.
  • A copy, such as a draft's file cloned from a published resource, keeps the source object's metadata.

Backfill for existing files

Files stored before this change keep whatever they had. Update them in the bucket. With the template's cache prefix for variants:

# originals (everything outside cache/), then variants
gcloud storage objects update "gs://<bucket>/**" --cache-control="public, max-age=31536000, immutable"
gcloud storage objects update "gs://<bucket>/cache/**" --cache-control="public, max-age=2592000"

Run the cache/** command second so it overwrites the first for variants, or use your own imagine cache prefix in its place. For S3, aws s3 cp s3://<bucket>/ s3://<bucket>/ --recursive --metadata-directive REPLACE --cache-control "…" does the same. It must also re-supply the content type: add --exclude/--include per type, or copy per object with --content-type.

Google Cloud CDN note

Behind Cloud CDN in CACHE_ALL_STATIC mode, the backend's clientTtl (default 3600) caps the max-age browsers receive, and maxTtl (default 86400) caps the edge copy. Raise them alongside this: gcloud compute backend-buckets update <name> --client-ttl=… --max-ttl=….

Lingua principale
Vue
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 components-web-app/docs

Tutte le issue di components-web-app/docs

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.