Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/cache/src/cache-headers/cache-headers.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, test, expect } from 'vitest'

import { cacheHeaders, ONE_YEAR } from './cache-headers.js'
import { cacheHeaders } from '../main.js'
import { ONE_YEAR } from './cache-headers.js'

describe('`cacheHaders`', () => {
describe('`tags`', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { caches } from './polyfill.js'
export { setCacheHeaders } from './cache-headers/cache-headers.js'
export { cacheHeaders, setCacheHeaders } from './cache-headers/cache-headers.js'
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps we should rename the method to netlifyCacheHeaders as it is not a generic cache headers function, it generates the netlify-cdn-cache-control, netlify-vary, netlify-cache-tag, and netlify-cache-id headers - what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great question. I'm a bit torn, to be honest. I don't think the goal of this package is to be a set of utility methods for HTTP caching. There are better alternatives like https://github.com/ascorbic/cache-primitives for that. I think the main use case is to provide a set of utility methods for working with the Netlify cache, and in that sense I think netlifyCacheHeaders is a bit redundant, as we'd also need to prefix setCacheHeaders (which we're currently not documenting) and potentially others, making the names more verbose and clunkier.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export { cacheHeaders, setCacheHeaders } from './cache-headers/cache-headers.js'
export { cacheHeaders as netlifyCacheHeaders, setCacheHeaders } from './cache-headers/cache-headers.js'

export { getCacheStatus } from './cache-status/cache-status.js'
export { fetchWithCache } from './fetchwithcache.js'
export * from './constants.js'
Loading