2017-05-13 4 views
6

나는 plunker와 같은 놀이터를 만들고자합니다. 나는 방금 localhost에서 작동하는 반면 Cloudflare에서는 active mode으로 매우 이상한 동작을 발견했습니다. iframe으로iframe의 src에있는 외부 파일이 캐시되지 않도록하기 (CloudFlare 사용)

는, 놀이터는 다른 파일에 대한 링크를 포함 할 수 있습니다 index_internal.html 미리보기 (예를 들어, .html, .js, .css). iframe<script src="script.js"></script>과 같은 외부 링크를 해석 할 수 있습니다.

그래서 사용자가 편집기에 자신의 파일을 (예를 들어, script.js) 수정 때마다, 내 프로그램 서버의 임시 폴더에 새 파일을 저장 한 후이 localhost에 잘 작동 iframe.src = iframe.src하여 iframe이 새로 고침.

그러나 사용자가 편집기에서 수정하고 새 버전이 서버의 폴더에 작성된 경우에도 브라우저는 항상 초기script.js을로드하는 것을 계속 인식했습니다. 예를 들어, Dev Tools ==> Network에서 볼 수있는 것은 script.js의 초기 버전이며 서버의 script.js의 새 버전은 less으로 확인할 수 있습니다.

왜 이런 이유인지 아시나요? 그리고 그것을 고치는 방법?

enter image description here

편집 1 :

은 내가 script.js 작동하지 않았다, 다음 시도 :

var iframe = document.getElementById('myiframe'); 
iframe.contentWindow.location.reload(true); 
iframe.contentDocument.location.reload(true); 
iframe.contentWindow.location.href = iframe.contentWindow.location.href 
iframe.contentWindow.src = iframe.contentWindow.src 
iframe.contentWindow.location.replace(iframe.contentWindow.location.href) 

가 나는 그것이 index_internal.html와 협력 버전을 추가하려고 시도를하지만, 다시로드하지 않았습니다. script.js :

var newSrc = iframe.src.split('?')[0] 
iframe.src = newSrc + "?uid=" + Math.floor((Math.random() * 100000) + 1); 

Cloudflare를 development mode으로 변경하면 script.js이로드되지만 Cloudflare를 active mode에 유지하고 싶습니다.

답변

관련 문제