티스토리 뷰
React :
리액트 앱 배포시 cache 안남게하기
https://stackoverflow.com/questions/49604821/cache-busting-with-create-react-app 참고
아래와 같이 unregister를 해주면 serviceworker가 작동하지 않아 캐시가 남지 않는다.
This is probably because of your web worker.
If you look into your index.js file you can see
registerServiceWorker();
Never wondered what it did? If we take a look at the file it got imported from we can see
// In production, we register a service worker to serve assets from local cache.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.
// To learn more about the benefits of this model, read {URL}
// This link also includes instructions on opting out of this behavior.
If you want to delete the web worker, don't just delete the line. Import unregister and call it in your file instead of the register.
import { unregister } from './registerServiceWorker';
and tell call
unregister()
P.S. When you unregister, it will take at least one refresh to make it work
'Front end > React' 카테고리의 다른 글
React- 리액트교과서 8장 학습내역 (확장성을 이용한 React 고차 컴포넌트-HOC) (0) | 2018.07.18 |
---|---|
React - 웹앱에서 휴대폰으로 찍은 사진 업로드시 이미지 회전해서 나올때 해결방법 (0) | 2018.07.13 |
React - 리액트 컴포넌트와 AWS S3와 연동해 사진 올리고 그 정보 받아오기 (0) | 2018.07.11 |
React - 리액트 교과서 7장 학습내역 (React에서 폼 다루기) (0) | 2018.07.09 |
React - 리액트교과서 6장 학습내역 (React에서 이벤트 다루기) (0) | 2018.07.06 |
댓글