I want to hide the source of JS from direct access. So I thought to produce a disposable JS file. I use a temporary session cookie. The cookie is set before including JS file and expires then.
rather than the idea itself, my exact question is that how a browser manipulate the JS file? Does it cache a copy of JS file as soon as we write <script>
tag or the script tag is just a reference and the browser should have access to JS file all times?
sample asp source:
<html>
<body>
<% response.cookies("tempJs")="yes"%>
<script src="myscripts.asp"></script>
<% response.cookies("tempJS")="no"%>
</body>
</html>
Sample disposable JavaScript (myscripts.asp):
<%
response.ContentType="text/javascript"
if request.cookies("tempJs")="yes" then
%>
document.write ("Hello world");
<%
end if
%>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…