1
0
mirror of synced 2025-12-30 12:02:01 -05:00

Merge pull request #31658 from github/revert-31657-peterbe-2287-set-max-age0-when-you-want-no-cache

Revert "set max-age=0 when you want no cache"
This commit is contained in:
Evan Bonsignori
2022-10-12 13:15:01 -07:00
committed by GitHub
5 changed files with 10 additions and 16 deletions

View File

@@ -26,7 +26,6 @@ export function cacheControlFactory(
maxAge && immutable && 'immutable',
!maxAge && 'private',
!maxAge && 'no-store',
maxAge === 0 && 'max-age=0',
]
.filter(Boolean)
.join(', ')

View File

@@ -9,7 +9,6 @@ import { SURROGATE_ENUMS } from '../../middleware/set-fastly-surrogate-key.js'
import { getPathWithoutVersion } from '../../lib/path-utils.js'
import { describe, jest } from '@jest/globals'
const NO_CACHE_CONTROL = 'private, no-store, max-age=0'
const AZURE_STORAGE_URL = 'githubdocs.azureedge.net'
const activeProducts = Object.values(productMap).filter(
(product) => !product.wip && !product.hidden
@@ -607,7 +606,7 @@ describe('server', () => {
expect(res.statusCode).toBe(302)
expect(res.headers['set-cookie']).toBeUndefined()
// no cache control because a language prefix had to be injected
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
})
test('redirects old articles to their slugified URL', async () => {
@@ -621,7 +620,7 @@ describe('server', () => {
const res = await get('/')
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe('/en')
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
expect(res.headers['set-cookie']).toBeUndefined()
})
@@ -640,7 +639,7 @@ describe('server', () => {
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe('/en')
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
expect(res.headers['set-cookie']).toBeUndefined()
})
@@ -654,7 +653,7 @@ describe('server', () => {
})
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe('/en')
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
expect(res.headers['set-cookie']).toBeUndefined()
})
@@ -664,7 +663,7 @@ describe('server', () => {
expect(res.headers.location.startsWith('/en/')).toBe(true)
expect(res.headers['set-cookie']).toBeUndefined()
// no cache control because a language prefix had to be injected
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
})
test('redirects that not only injects /en/ should have cache-control', async () => {

View File

@@ -4,8 +4,6 @@ import enterpriseServerReleases from '../../lib/enterprise-server-releases.js'
import { get, getDOM } from '../helpers/e2etest.js'
import { SURROGATE_ENUMS } from '../../middleware/set-fastly-surrogate-key.js'
const NO_CACHE_CONTROL = 'private, no-store, max-age=0'
jest.useFakeTimers({ legacyFakeTimers: true })
describe('enterprise deprecation', () => {
@@ -98,7 +96,7 @@ describe('recently deprecated redirects', () => {
expect(res.headers.location).toBe('/en/enterprise-server@3.0')
expect(res.headers['set-cookie']).toBeUndefined()
// Deliberately no cache control because it is user-dependent
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
})
test('already languaged enterprise 3.0 redirects', async () => {
@@ -117,7 +115,7 @@ describe('recently deprecated redirects', () => {
expect(res.statusCode).toBe(302)
expect(res.headers['set-cookie']).toBeUndefined()
// Deliberately no cache control because it is user-dependent
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
// This is based on
// https://github.com/github/help-docs-archived-enterprise-versions/blob/master/3.0/redirects.json
expect(res.headers.location).toBe(

View File

@@ -126,7 +126,7 @@ describe('redirects', () => {
const res = await get('/')
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe('/en')
expect(res.headers['cache-control']).toBe('private, no-store, max-age=0')
expect(res.headers['cache-control']).toBe('private, no-store')
})
test('trailing slash on languaged homepage should permantently redirect', async () => {

View File

@@ -2,8 +2,6 @@ import { languageKeys } from '../../lib/languages.js'
import { get } from '../helpers/e2etest.js'
import { PREFERRED_LOCALE_COOKIE_NAME } from '../../lib/constants.js'
const NO_CACHE_CONTROL = 'private, no-store, max-age=0'
const langs = languageKeys.filter((lang) => lang !== 'en')
describe('redirects', () => {
@@ -14,7 +12,7 @@ describe('redirects', () => {
})
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe(`/${lang}/get-started`)
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
expect(res.headers['set-cookie']).toBeUndefined()
})
@@ -28,7 +26,7 @@ describe('redirects', () => {
})
expect(res.statusCode).toBe(302)
expect(res.headers.location).toBe(`/${lang}/get-started`)
expect(res.headers['cache-control']).toBe(NO_CACHE_CONTROL)
expect(res.headers['cache-control']).toBe('private, no-store')
expect(res.headers['set-cookie']).toBeUndefined()
})