Skip to content

Commit

Permalink
Add cache headers
Browse files Browse the repository at this point in the history
  • Loading branch information
colepeters committed Apr 10, 2024
1 parent 7384192 commit 40583fb
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/api/$$.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import cacheControl from '../lib/cache-control.mjs'

export async function get() {
return {
headers: {
'cache-control': cacheControl,
},
}
}
5 changes: 5 additions & 0 deletions app/api/photographs/blackwhite.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import cacheControl from '../../lib/cache-control.mjs'

export async function get() {
return {
headers: {
'cache-control': cacheControl,
},
json: {
artworks: [
{
Expand Down
5 changes: 5 additions & 0 deletions app/api/photographs/heir.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import cacheControl from '../../lib/cache-control.mjs'

export async function get() {
return {
headers: {
'cache-control': cacheControl,
},
json: {
artworks: [
{
Expand Down
5 changes: 5 additions & 0 deletions app/api/photographs/images-pour-rien.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import cacheControl from '../../lib/cache-control.mjs'

export async function get() {
return {
headers: {
'cache-control': cacheControl,
},
json: {
artworks: [
{
Expand Down
5 changes: 5 additions & 0 deletions app/api/photographs/locus.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import cacheControl from '../../lib/cache-control.mjs'

export async function get() {
return {
headers: {
'cache-control': cacheControl,
},
json: {
artworks: [
{
Expand Down
5 changes: 5 additions & 0 deletions app/api/photographs/northern-italy.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import cacheControl from '../../lib/cache-control.mjs'

export async function get() {
return {
headers: {
'cache-control': cacheControl,
},
json: {
artworks: [
{
Expand Down
5 changes: 5 additions & 0 deletions app/api/photographs/protest.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import cacheControl from '../../lib/cache-control.mjs'

export async function get() {
return {
headers: {
'cache-control': cacheControl,
},
json: {
artworks: [
{
Expand Down
5 changes: 5 additions & 0 deletions app/lib/cache-control.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const cacheControl = process.env.ARC_ENV === 'production'
? 'max-age=1800;'
: 'no-cache, no-store, must-revalidate, max-age=0, s-maxage=0'

export default cacheControl

0 comments on commit 40583fb

Please sign in to comment.