동기화 저장소와 로컬 저장소 및 할당량
적절한 Chrome 저장 영역을 선택하고 할당량 제한을 이해하며 저장소 변경 이벤트를 안정적으로 처리합니다.
동기화 저장소와 로컬 저장소 및 할당량은(는) CoddyKit의 무료 Browser Extensions Development (Chrome & Edge) 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Browser Extensions Development (Chrome & Edge) 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Browser Extensions Development (Chrome & Edge) 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Two Main Storage Areas
The Chrome storage API offers several areas. The two you use most are storage.local and storage.sync.
- local — stays on this device, larger quota
- sync — syncs across the user's signed-in browsers, smaller quota
When to Use sync
Use storage.sync for user preferences you want to follow them everywhere, like theme or settings. Keep the data small.
chrome.storage.sync.set({ theme: 'dark', fontSize: 14 })When to Use local
Use storage.local for larger or device-specific data such as caches, logs, or downloaded content that does not need to sync.
chrome.storage.local.set({ cache: bigObject })Sync Quota Limits
storage.sync is intentionally small. Roughly: about 100 KB total, 8 KB per item, and a limited number of writes per minute.
Exceeding these throws errors, so plan your data shape.
// Stay well under ~8 KB per key for syncLocal Quota Limits
storage.local allows far more, commonly around 10 MB by default, and the unlimitedStorage permission can raise it. Still avoid storing huge blobs.
{
"permissions": ["storage", "unlimitedStorage"]
}Reading Data Back
Both areas read with get. Pass a key, an array of keys, or an object of defaults.
const data = await chrome.storage.sync.get({ theme: 'light' })
console.log(data.theme)Watching for Changes
The onChanged event fires whenever stored values change, even from another context. Use it to keep your UI in sync.
chrome.storage.onChanged.addListener((changes, area) => {
if (area === 'sync' && changes.theme) {
console.log('New theme: ' + changes.theme.newValue)
}
})Removing and Clearing
Delete specific keys with remove, or wipe an entire area with clear.
chrome.storage.local.remove('cache')
chrome.storage.sync.clear()Checking Bytes Used
Use getBytesInUse to see how close you are to the quota before writing more data.
const used = await chrome.storage.sync.getBytesInUse()
console.log(used + ' bytes used')Handling Write Failures
Sync writes can fail on quota errors. Wrap writes in try/catch and fall back to local storage when sync is full.
try {
await chrome.storage.sync.set({ big: value })
} catch (e) {
await chrome.storage.local.set({ big: value })
}Choosing Wisely
A common pattern: keep small settings in sync, keep everything else in local. Never store secrets like tokens in plain storage, since extension storage is not encrypted.
Quick Check
Test your storage knowledge.
Recap
You compared storage areas:
syncfor small cross-device settingslocalfor larger device data- Respect quotas and check
getBytesInUse - React to
onChanged - Handle write failures and avoid storing secrets
Picking the right area keeps your data fast, durable, and within limits.
자주 묻는 질문
“동기화 저장소와 로컬 저장소 및 할당량” 강의는 무료인가요?
네 — “동기화 저장소와 로컬 저장소 및 할당량” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Browser Extensions Development (Chrome & Edge) 강의 전체를 잠금 해제할 수 있습니다. Browser Extensions Development (Chrome & Edge) 강의에는 총 4개의 강의가 포함되어 있습니다.
“동기화 저장소와 로컬 저장소 및 할당량”에서 뭘 배우나요?
적절한 Chrome 저장 영역을 선택하고 할당량 제한을 이해하며 저장소 변경 이벤트를 안정적으로 처리합니다. 브라우저에서 직접 실행하는 실습 코드로 Browser Extensions Development (Chrome & Edge)을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Browser Extensions Development (Chrome & Edge)을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Browser Extensions Development (Chrome & Edge)은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“동기화 저장소와 로컬 저장소 및 할당량” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Browser Extensions Development (Chrome & Edge) 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Browser Extensions Development (Chrome & Edge) 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 단방향 메시징 패턴
- 구성 요소 간 양방향 메시징
- Chrome Storage API 사용
- 동기화 저장소와 로컬 저장소 및 할당량