Skip to content

Commit b2b8ab4

Browse files
authored
Daniel vf/caching and static pages (#589)
* Allow pre-rendered pages to be used and enable caching. * Allow staging to be deployed without analytics.
1 parent 6e2b173 commit b2b8ab4

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

dapp/deploy.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ if [ $branch != "master" ]; then
1212
fi
1313
fi
1414

15-
# .next folder is only needed for local development. Deleting it circumvents the following error:
15+
# .next/cache is only needed for local development. Deleting it circumvents the following error:
1616
# Error Response: [3] The directory [.next/cache/next-babel-loader] has too many files (greater than 1000)..
17+
# The actual .next folder is useful because it contains pre-rendered static versions of all pages that
18+
# can be staticly rendered, which is most of OUSD.com
1719
echo "Deleting .next folder..."
18-
rm -rf .next
20+
rm -rf .next/cache
1921

2022
echo "Decrypting secrets..."
2123
yarn run decrypt-secrets-deploy:$mode

dapp/next.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ module.exports = {
7474
{
7575
key: 'X-Frame-Options',
7676
value: 'SAMEORIGIN',
77+
},
78+
{
79+
// Cache all pages for 10 minutes, give server an extra 2 minutes
80+
// to regenerate the content in the background during which the
81+
// cache can still keep serving the content it has.
82+
key: 'Cache-Control',
83+
value: 'public, max-age=600, stale-while-revalidate=120',
7784
}
7885
]
7986
}

dapp/src/utils/analytics.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,27 @@ if (isProduction && !isStaging) {
1212
mixpanelId = MIXPANEL_ID
1313
}
1414

15-
const analytics = Analytics({
16-
app: 'origin-dollar-dapp',
17-
version: 1,
18-
plugins: [
15+
const plugins = []
16+
17+
if (process.env.GA_ID || !isStaging) {
18+
plugins.push(
1919
googleAnalytics({
2020
trackingId: process.env.GA_ID,
2121
debug: isDevelopment ? true : false,
22-
}),
23-
mixpanel({
24-
token: mixpanelId,
25-
}),
26-
],
22+
})
23+
)
24+
}
25+
26+
plugins.push(
27+
mixpanel({
28+
token: mixpanelId,
29+
})
30+
)
31+
32+
const analytics = Analytics({
33+
app: 'origin-dollar-dapp',
34+
version: 1,
35+
plugins: plugins,
2736
})
2837

2938
export default analytics

0 commit comments

Comments
 (0)