Skip to content

Commit 72be381

Browse files
authored
Merge pull request #163 from sipe-team/feat/5th-recruit
feat: 캐시 무효화를 위한 asset version 추가
2 parents 78665f8 + fad329b commit 72be381

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

@types/environment.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ namespace NodeJS {
77
KEY: string;
88
NEXT_PUBLIC_GA_MEASUREMENT_ID: string;
99
NEXT_PUBLIC_ORIGIN: string;
10+
NEXT_PUBLIC_ASSET_VERSION: string;
1011
}
1112
}

src/app/layout.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { pretendardFont } from '@/app/_fonts';
99
import ClientProvider from '@/components/global/ClientProvider';
1010
import Footer from '@/components/global/Footer';
1111
import Navigation from '@/components/global/Navigation';
12+
import { ASSET_VERSION } from '@/libs/constants/assetVersion';
1213
import { DEFAULT_METADATA } from '@/libs/constants/metadata';
1314

1415
import styles from './layout.module.scss';
@@ -19,18 +20,21 @@ function RootLayout({ children }: { children: React.ReactNode }) {
1920
return (
2021
<html lang="ko" className={pretendardFont.className}>
2122
<head>
22-
<link rel="mask-icon" href="/assets/safari-pinned-tab.svg" />
23+
<link
24+
rel="mask-icon"
25+
href={`/assets/safari-pinned-tab.svg?v=${ASSET_VERSION}`}
26+
/>
2327
<link
2428
rel="icon"
2529
type="image/png"
2630
sizes="32x32"
27-
href="/assets/favicon-32x32.png"
31+
href={`/assets/favicon-32x32.png?v=${ASSET_VERSION}`}
2832
/>
2933
<link
3034
rel="icon"
3135
type="image/png"
3236
sizes="16x16"
33-
href="/assets/favicon-16x16.png"
37+
href={`/assets/favicon-16x16.png?v=${ASSET_VERSION}`}
3438
/>
3539
</head>
3640
<body>

src/app/manifest.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { MetadataRoute } from 'next';
22

3+
import { ASSET_VERSION } from '@/libs/constants/assetVersion';
4+
35
function manifest(): MetadataRoute.Manifest {
46
return {
57
name: 'SIPE',
@@ -11,27 +13,27 @@ function manifest(): MetadataRoute.Manifest {
1113
theme_color: '#131518',
1214
icons: [
1315
{
14-
src: '/favicon.ico',
16+
src: `/favicon.ico?v=${ASSET_VERSION}`,
1517
sizes: '48x48',
1618
type: 'image/x-icon',
1719
},
1820
{
19-
src: '/assets/favicon-16x16.png',
21+
src: `/assets/favicon-16x16.png?v=${ASSET_VERSION}`,
2022
sizes: '16x16',
2123
type: 'image/png',
2224
},
2325
{
24-
src: '/assets/favicon-32x32.png',
26+
src: `/assets/favicon-32x32.png?v=${ASSET_VERSION}`,
2527
sizes: '32x32',
2628
type: 'image/png',
2729
},
2830
{
29-
src: '/assets/android-chrome-192x192.png',
31+
src: `/assets/android-chrome-192x192.png?v=${ASSET_VERSION}`,
3032
sizes: '192x192',
3133
type: 'image/png',
3234
},
3335
{
34-
src: '/assets/android-chrome-512x512.png',
36+
src: `/assets/android-chrome-512x512.png?v=${ASSET_VERSION}`,
3537
sizes: '512x512',
3638
type: 'image/png',
3739
},

src/libs/constants/assetVersion.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* 자산 캐시 무효화를 위한 버전 관리
3+
*
4+
* - Vercel 환경: NEXT_PUBLIC_ASSET_VERSION 환경 변수 사용
5+
* - 로컬 개발: 현재 날짜 기반 버전 사용
6+
*
7+
* 외부 플랫폼(Notion, Slack 등)의 메타데이터 캐시를 무효화하기 위해
8+
* OG 이미지, favicon 등의 경로에 버전 파라미터로 추가됩니다.
9+
*/
10+
export const ASSET_VERSION =
11+
process.env.NEXT_PUBLIC_ASSET_VERSION || 'sipe-5th';

src/libs/constants/metadata.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { Metadata } from 'next';
22

3+
import { ASSET_VERSION } from './assetVersion';
4+
35
const title = 'SIPE';
46
const description = '개발자들이 함께 교류하며 성장하는 IT 커뮤니티';
5-
const images = ['/assets/logos/og-image.png'];
7+
const images = [`/assets/logos/og-image.png?v=${ASSET_VERSION}`];
68
const defaultURL = process.env.NEXT_PUBLIC_ORIGIN;
79
const metadataBase = new URL(defaultURL);
810

0 commit comments

Comments
 (0)