프로그래밍/기타
Flask에서 No-Cache 헤더 설정
snoopybox
2018. 5. 29. 18:59
Flask로 만든 웹서버가 있는데, 보안 권고사항을 적용하여 No-Cache 헤더를 설정하여 테스트 하던 중, 가이드 내용대로 추가했지만 Chrome에서 여전히 캐싱을 하길래...
구글링 후 아래와 같이 몇가지 string을 더 추가하니 잘 작동하였다.
@app.after_request def set_response_headers(r): r.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' r.headers['Pragma'] = 'no-cache' r.headers['Expires'] = '0' return r