2021. 10. 19. 12:45ㆍ업무관련
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
html 캐시삭제, 캐시방지 방법 모음
Web Storage 웹 스토로지 관련
http://202psj.tistory.com/1187
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
how to clear localstorage,sessionStorage and cookies in javascript? and then retrieve?
How to completely clear localstorage, sessionStorage and cookies in javascript ? Is there any way one can get these values back after clearing them ?
stackoverflow.com
How to completely clear localstorage, sessionStorage and cookies in javascript ?
Is there any way one can get these values back after clearing them ?
how to completely clear localstorage
localStorage.clear();
how to completely clear sessionstorage
sessionStorage.clear();
[...] Cookies ?
var cookies = document.cookie; for (var i = 0; i < cookies.split(";").length; ++i) { var myCookie = cookies[i]; var pos = myCookie.indexOf("="); var name = pos > -1 ? myCookie.substr(0, pos) : myCookie; document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; }
is there any way to get the value back after clear these ?
No, there isn't. But you shouldn't rely on this if this is related to a security question.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
출처: https://www.lesstif.com/pages/viewpage.action?pageId=20775788
Java Servlet
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0. response.setDateHeader("Expires", 0); // Proxies. |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
모든 브라우저에서 다되는지는 아직 확인 못해보았다~!
<!-- Cache Refresh-->
<script>
var url = location.href;
var tmpUrl = url + ((/\?/).test(url) ? "&" : "?") + (new Date()).getTime();
var oReq = new XMLHttpRequest();
oReq.open("GET", tmpUrl, false); //또는 oReq.open("GET", tmpUrl, true);
oReq.send(null);
</script>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[Javascript] 브라우져 캐시 우회하기
XMLHttpRequest 객체를 이용해 서버와 AJAX 통신을 하던 도중, 다음과 같은 문제가 발생하였습니다. - A.js 파일을 수정한 후 해당 파일을 비동기로 로드했지만, 수정되지 않은채 로드가 되었습니다.
gafani.tistory.com
XMLHttpRequest 객체를 이용해 서버와 AJAX 통신을 하던 도중, 다음과 같은 문제가 발생하였습니다.
- A.js 파일을 수정한 후 해당 파일을 비동기로 로드했지만, 수정되지 않은채 로드가 되었습니다.
구글링 통해 알아본 결과 브라우져에서 캐싱하는듯 합니다. 브라우져에서 캐시를 삭제한 후 다시 로드하니 수정된 내용이 로드되었습니다.
조금 더 구글링 해본 결과 Mozilla 사이트에서 해당 내용을 우회할 수 있는 법이 있었습니다. (원문 바로 가기)
내용을 보아 하니 캐시를 우회하는 법은 요청하려는 URL 뒤에 timestamp를 붙여주는 것입니다. "?" 또는 "&" 말이지요.
샘플을 보시면:
http://foo.com/bar.html -> http://foo.com/bar.html?12345 http://foo.com/bar.html?foobar=baz -> http://foo.com/bar.html?foobar=baz&12345
이렇게 말이죠.
하지만 하드코딩하지 않는 이상, 매번 저렇게 하기엔 동적이지 않아 다음처럼 자동으로 URL을 만들어 줄 수 있다고 하네요:
var oReq = new XMLHttpRequest(); oReq.open("GET", url + ((/\?/).test(url) ? "&" : "?") + (new Date()).getTime()); oReq.send(null);
이렇게 작성 하시면, 호출 할 때마다 현재 timestamp를 URL 뒤에 "?" 또는 "&" 자동으로 붙여 줍니다.
출처: http://gafani.tistory.com/entry/Javascript-브라우져-캐시-우회하기 [Sanctuary]
'업무관련' 카테고리의 다른 글
Log4j 취약점 무료 점검 도구 (0) | 2021.12.17 |
---|---|
제일기획 - 빅데이터마케팅 2017.10.13 (0) | 2021.11.01 |
(to 김남국 책임) Xwiki 첨부파일 업로드시 인코딩 문제 (at Jeus 7) (0) | 2021.10.12 |
[JS] iframe 간 통신 (MessageChannel API) (1) | 2021.10.08 |
[xwiki] Space URL with literal space in title get renamed after saving (0) | 2021.09.16 |