Skip to content

Conversation

@purplecabbage
Copy link
Member

@purplecabbage purplecabbage commented Oct 30, 2025

Description

This is an alternative to #227 and is non-breaking.
Priority is given to cache-control headers defined with normal custom-header wildcards.
If appConfig values are present for htmlCacheDuration(|js|css|image) they will be used, but s-max-age will be set to 60 by default.
If no cache headers are explicitly set, they will not be added to the metadata.

note: there will be another pr to app-config to remove defaults and only load values if explicitly specified

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@purplecabbage purplecabbage changed the title wip: allow setting cache control headers - alternative Allow setting cache control headers - alternative Nov 13, 2025
Copilot finished reviewing on behalf of purplecabbage November 13, 2025 19:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for configurable cache control headers as a non-breaking alternative to PR #227. The implementation prioritizes cache-control headers defined via response header wildcards over appConfig values, changes the default s-maxage from 0 to 60, and only adds cache headers when explicitly configured.

Key Changes:

  • Modified cache control logic to support override via adp-cache-control response headers
  • Changed default s-maxage value from 0 to 60 seconds
  • Updated to return null instead of default cache control strings when values are not explicitly configured
  • Upgraded Parcel from ^2.7.0 to ^2.15.4

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
package.json Upgrades Parcel dependency from version 2.7.0 to 2.15.4
lib/remote-storage.js Implements cache control header override logic, modifies default behavior to only set cache headers when explicitly configured, adds JSDoc for canAddHeader method, and changes Metadata to always be set as an object
Comments suppressed due to low confidence (5)

lib/remote-storage.js:145

  • Missing space after if keyword. The codebase consistently uses if ( with a space (see other occurrences in the file). Please add a space between if and the opening parenthesis for consistency.
   */

lib/remote-storage.js:301

  • Potential bug: If appConfig.htmlCacheDuration is undefined, this will produce an invalid cache-control string like s-maxage=60, max-age=undefined. Consider checking if the cache duration property exists before constructing the string, or returning null if it doesn't exist (similar to the else case on line 309).
      fileBatch = files.splice(0, batchSize)

lib/remote-storage.js:303

  • Potential bug: If appConfig.jsCacheDuration is undefined, this will produce an invalid cache-control string like s-maxage=60, max-age=undefined. Consider checking if the cache duration property exists before constructing the string, or returning null if it doesn't exist (similar to the else case on line 309).
    return allResults

lib/remote-storage.js:305

  • Potential bug: If appConfig.cssCacheDuration is undefined, this will produce an invalid cache-control string like s-maxage=60, max-age=undefined. Consider checking if the cache duration property exists before constructing the string, or returning null if it doesn't exist (similar to the else case on line 309).
    lib/remote-storage.js:307
  • Potential bug: If appConfig.imageCacheDuration is undefined, this will produce an invalid cache-control string like s-maxage=60, max-age=undefined. Consider checking if the cache duration property exists before constructing the string, or returning null if it doesn't exist (similar to the else case on line 309).
    * Get cache control string based on mime type and config

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@purplecabbage purplecabbage merged commit 8820d96 into master Nov 15, 2025
15 checks passed
@purplecabbage purplecabbage deleted the AllowCacheHeaders branch November 15, 2025 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants