Skip to content

Commit cbe9282

Browse files
committed
use proper cache header
1 parent 42c90b0 commit cbe9282

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

packages/gatsby-theme/src/components/HamburgerMenu/index.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import {
99
import menuData from '@dvcorg/gatsby-theme/src/data/menu'
1010
import { logEvent } from '@dvcorg/gatsby-theme/src/utils/front/plausible'
1111

12+
import { ReactComponent as MailIcon } from '../../../../../static/img/community/icon-mail.svg'
1213
import HamburgerIcon from '../HamburgerIcon'
1314
import Link from '../Link'
15+
import { ReactComponent as DiscordSVG } from '../SocialIcon/discord.svg'
1416
import { ReactComponent as GithubIcon } from '../SocialIcon/github.svg'
1517
import { ReactComponent as TwitterIcon } from '../SocialIcon/twitter.svg'
1618

@@ -154,11 +156,7 @@ export const HamburgerMenu: React.FC<
154156
target="_blank"
155157
onClick={() => handleItemClick('mail')}
156158
>
157-
<img
158-
className={styles.subSectionLinkImage}
159-
src="/img/community/icon-mail.svg"
160-
alt=""
161-
/>
159+
<MailIcon className={styles.subSectionLinkImage} />
162160
<span className={styles.subSectionLinkTitle}>E-Mail</span>
163161
</Link>
164162
</li>
@@ -180,11 +178,7 @@ export const HamburgerMenu: React.FC<
180178
onClick={() => handleItemClick('chat')}
181179
target="_blank"
182180
>
183-
<img
184-
className={styles.subSectionLinkImage}
185-
src="/img/community/icon-discord.svg"
186-
alt=""
187-
/>
181+
<DiscordSVG className={styles.subSectionLinkImage} />
188182
<span className={styles.subSectionLinkTitle}>Discord</span>
189183
</Link>
190184
</li>

scripts/heroku-deploy.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ ln -s $NEWPWD $OLDPWD
88
cd $NEWPWD
99
yarn build
1010
rm -rf static .cache
11-
# Copy the 404 HTML file from public into the root dir for Heroku
1211
./scripts/clear-cloudfront-cache.js

server/index.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,36 @@ app.use(
8484
)
8585
app.use(helmet(helmetOptions))
8686

87+
const mustRevalidate = 'public, max-age=0, must-revalidate'
88+
const cacheForever = 'public, max-age=31536000, immutable'
8789
const serveMiddleware = async (req, res) => {
8890
await serveHandler(req, res, {
8991
public: 'public',
9092
cleanUrls: true,
9193
trailingSlash: false,
92-
directoryListing: false
94+
directoryListing: false,
95+
headers: [
96+
{
97+
source: '**/*.html',
98+
headers: [{ key: 'Cache-Control', value: mustRevalidate }]
99+
},
100+
{
101+
source: 'page-data/**',
102+
headers: [{ key: 'Cache-Control', value: mustRevalidate }]
103+
},
104+
{
105+
source: 'static/**',
106+
headers: [{ key: 'Cache-Control', value: cacheForever }]
107+
},
108+
{
109+
source: '**/*.@(css|js)',
110+
headers: [{ key: 'Cache-Control', value: cacheForever }]
111+
},
112+
{
113+
source: '**/*.@(jpg|jpeg|gif|png|svg)',
114+
headers: [{ key: 'Cache-Control', value: 'max-age=86400' }]
115+
}
116+
]
93117
})
94118
}
95119
app.use(serveMiddleware)

0 commit comments

Comments
 (0)