Skip to content

Latest commit

 

History

History
277 lines (153 loc) · 8.47 KB

CHANGELOG.md

File metadata and controls

277 lines (153 loc) · 8.47 KB

@web-widget/shared-cache

2.1.0

Minor Changes

  • 932f1c2: Upgrade to @web-widget/http-cache-semantics 2.0.1 and migrate cache policy evaluation to evaluateRequest().

    • Normalize requests at the cache layer before calling evaluateRequest() (replacing removed CacheQueryOptions)
    • Use evaluateRequest() for stale-while-revalidate and synchronous revalidation
    • Rely on revalidatedPolicy() for stale-if-error handling (removed public useStaleIfError())

2.0.0

Major Changes

  • 4b5004c: Fix cache key safety, HTTP semantics, and Vary handling:

    • Reduce wrong cache hits from digest collisions — cookie/header/device values are hashed with a single standard SHA-1 digest over a canonical string, instead of per-value truncated digests that could collide at scale.
    • Stop http and https from sharing the same entry — URL scheme is included in default keys so representations are not mixed across schemes (RFC 9111 URI identity).
    • Make Vary-aware keys unambiguous — use explicit |v| / |vary| suffixes so base keys, Vary metadata, and variants cannot be parsed incorrectly.
    • Keep keys debuggable without exposing secrets — fragment key names stay visible (#cookie:a|header:x-id@…); only normalized values are digested.
    • Align cache lookup options with Workers Cache API — match() / delete() support ignoreMethod only; ignore query strings via cacheKeyRules.search: false, and bypass Vary via sharedCache.ignoreVary.

    Breaking: Existing cache entries miss until they expire or are revalidated. Set scheme: false to keep the previous host-first URL shape. Remove cacheKeyPartDefiners / SharedCacheKeyPartDefiners; use built-in cacheKeyRules only.

Minor Changes

  • 6f8b479: Simplify the package internals with no intended behavior change for supported public APIs.

    Breaking: Deprecated logger helpers are removed. Use createLogger(logger, level, 'SharedCache') instead of createSharedCacheLogger(logger, level).

    Breaking: Rename public types for consistent naming: SharedCacheKeyRules → CacheKeyRules, FilterOptions → KeyFilterOptions, SharedCacheLogContext → CacheLogContext, SharedCacheStatus → CacheStatus.

1.9.0

Minor Changes

  • e7a9731: Fix 304 revalidation persistence so background revalidation with 304 Not Modified stores the revalidated policy instead of rebuilding from stale response headers (restores fresh HIT on subsequent requests).

    Add UPDATING cache status for stale-while-revalidate (aligns with Cloudflare CDN semantics; STALE is reserved for stale-if-error).

    Return 304 Not Modified from Cache.match() when conditional request headers (If-None-Match, If-Modified-Since) match a fresh cached entry.

    Percent-encode x-cache-key header values so cache keys with control characters or non-Latin-1 Unicode are valid HTTP header field values.

    Strip persisted Age from stored policy metadata on read for compatibility with entries written before the revalidation fix.

  • 2aeb468: Add middleware-friendly resolveWithCache and createCacheHandler APIs with phase-aware origin error handling.

1.8.0

Minor Changes

  • db9675c: Add debugCacheKey support to expose the computed cache key via x-cache-key for diagnostics.

    Unify cache status constant naming to CACHE_STATUS_HEADER_NAME and export CACHE_KEY_HEADER_NAME for downstream integrations.

1.7.2

Patch Changes

  • 1c29aaa: fix: Comprehensive fix for readonly headers modification issues

    This change completely resolves the readonly headers modification problems that were partially addressed in the previous fix. The solution includes:

    New Features:

    • Added src/utils/response.ts with intelligent response utilities:
      • modifyResponseHeaders(): Smart header modification with readonly fallback
      • setResponseHeader(): Convenient single header setting function

    Bug Fixes:

    • Fixed setCacheStatus() function in fetch.ts to properly handle readonly headers
    • Optimized createInterceptor() function to avoid unnecessary Response cloning
    • Ensured cache.ts uses safe header modification patterns
    • All header modifications now gracefully handle readonly scenarios

    Performance Improvements:

    • No Response cloning when no header overrides are configured
    • Direct header modification when possible (for mutable headers)
    • Smart fallback to new Response creation only when necessary
    • Significant performance improvement for common use cases

    Testing:

    • Added comprehensive unit tests for response utilities (10 new tests)
    • Added specific tests for createInterceptor readonly headers handling (6 new tests)
    • All 258 tests pass with 93.93% code coverage
    • Tests cover edge cases, error scenarios, and performance considerations

    This fix ensures that header modifications work reliably across all environments (browser, Node.js, etc.) while maintaining optimal performance by avoiding unnecessary object creation.

1.7.1

Patch Changes

  • b309ee1: fix: Fix Response headers modification bug in createInterceptor function

    The createInterceptor function was attempting to directly modify the Response.headers object, which is read-only in both browser and Node.js environments. This caused the cacheControlOverride and varyOverride options to not work properly.

    Changes made:

    • Create a new Headers object from the original response headers
    • Apply header modifications to the new Headers object
    • Create a new Response object with the modified headers
    • Return the new Response for successful responses

    This fix ensures that cacheControlOverride and varyOverride work correctly for successful responses while maintaining backward compatibility.

1.7.0

Minor Changes

  • 674dbd1: Replace waitUntil with event field for ExtendableEvent support.

1.6.0

Minor Changes

  • 16fa4a5: Optimizing the logger.

1.5.0

Minor Changes

  • 4520827: Enhanced logging system with structured output and multiple log levels.

1.4.0

Minor Changes

  • 1d9e185: Remove dependency - @web-widget/helpers.

1.3.0

Minor Changes

  • 8d2ad75: new createFetch interface.

1.2.0

Minor Changes

  • b5b9258: Update dependencies.

1.1.0

Minor Changes

  • 5ea20fb: The waitUntil option can be used to extend the life of background tasks.

1.0.0

Major Changes

  • 0adbc60: Reduce the deviation from the mainstream edge worker environment's Cache API implementation.
  • 8682fd6: - Support ignoreMethod option.
    • Support ignoreRequestCacheControl option.
    • Ignore spaces in cache keys.

Minor Changes

  • 80b5a4b: Added ignoreVary option.

Patch Changes

  • 98bdedb: - The stale-while-revalidate and stale-if-error directives are not supported when using the cache.put or cache.match methods.
    • Support HEAD requests.
  • b3761de: Fix Request.cache equal to "default" will cause exception.

1.0.0-next.3

Minor Changes

  • 80b5a4b: Added ignoreVary option.

1.0.0-next.2

Patch Changes

  • b3761de: Fix Request.cache equal to "default" will cause exception.

1.0.0-next.1

Patch Changes

  • 98bdedb: - The stale-while-revalidate and stale-if-error directives are not supported when using the cache.put or cache.match methods.
    • Support HEAD requests.

1.0.0-next.0

Major Changes

  • 8682fd6: - Support ignoreMethod option.
    • support ignoreRequestCacheContro option.
    • Ignore spaces in cache keys.

0.4.2

Patch Changes

  • 6596e83: Reduce the frequency of cache revalidation.

0.4.1

Patch Changes

  • cbe32be: Optimize the order of logs and vary in cache keys.

0.4.0

Minor Changes

  • 6603ef3: Support custom logger.

0.3.0

Minor Changes

  • be3d4d6: cacheName will be added to the prefix of cache key.

0.2.3

Patch Changes

  • bec7c90: Avoid strict instance checks leading to run failures.

0.2.2

Patch Changes

  • 453e7ee: Improve error handling.

0.2.1

Patch Changes

  • 1c7d03c: Fix Cache.put: Response body is locked or disturbed error.

0.2.0

Minor Changes

  • dc275c7: Make the post method’s caching logic comply with standards.

0.1.2

Patch Changes

  • 98a3a1a: Fixed the problem of failing to process logs correctly after updating the cache error.

0.1.1

Patch Changes

  • d1aa8b2: Fix cacheControlOverride not being overridden correctly.

0.1.0

Minor Changes

  • c7f91c9: Delete CacheStorage.delete() API.

0.0.2

Patch Changes

  • c3db08e: Refactor types.

0.0.1

Patch Changes

  • fbffa04: Initial version.