ASP Classic deleting cache files after user clicks “Done” button

temtem

New Member
Good morning everyone,I am working on a legacy ASP Classic application which needs some upgrading and refactoring. One of the biggest improvements that needed to be made was to speed up the app by caching the results from database. This I have been able to do successfully by caching them to .dat files. This application follows a specific path so I have been deleting the unused cache files after I am done with them. However, on the final .asp page of the application (PV.asp), the files are getting deleted when they shouldn't be.My intention is this,\[code\] <input type="button" value="http://stackoverflow.com/questions/12567998/Done" style="width: 56px; height: 40px" onclick="finish()" />\[/code\]^ this is the code for the "Done" button, it calls the finish() function. Which is below:\[code\] function finish() { var size = "<%response.write(size) %>"; if (size == "0") { var done = confirm("All Items mod, would you like to save?"); if (done == true) { if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } var concode = "<%=Replace(concode, "\", "\\" )%>"; xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('concode').value = http://stackoverflow.com/questions/12567998/concode; document.forms["confirm"].submit(); } } <%if NOT rsTrxTy.EOF then if rsTrxTy.fields("TYPE").value = "http://stackoverflow.com/questions/12567998/TO" then%> ~Stuff happens here~ <%end if if rsTrxTy.fields("TYPE").value = "http://stackoverflow.com/questions/12567998/TI" then%> ~Stuff happens here~ <%end if end if if NOT rsOrdrs.EOF then%> ~Stuff happens here~ <%end if %> <% dim fso Set fso = Server.CreateObject("Scripting.FileSystemObject") fso.DeleteFile "C:\M\cache\rstrxis-" & Session.SessionID & ".dat" fso.DeleteFile "C:\M\cache\rstrxos-" & Session.SessionID & ".dat" fso.DeleteFile "C:\M\cache\rstrxty-" & Session.SessionID & ".dat" fso.DeleteFile "C:\M\cache\rsords-" & Session.SessionID & ".dat" %> } } else { alert("All items have not been mod."); } }\[/code\]When the user clicks the "Done" button, the changes made to the items are committed to the database. My intention is that when this action is being performed, the cached files are deleted. However, the DeleteFile command runs even if the user doesn't click the "done" button. It runs once the page has finished loading. This causes problems since the page will try to load from the cached file which were deleted when PV.asp was loaded. Since this app is intended to be used almost constantly without the window being closed, the session ID will remain the same which leaves not deleting the cached files out of the question (since when the app is restarted it will attempt to load what has already been cached).My question is, why are the files being deleted when they are supposed to be contained in a javascript function that only executes when the user clicks done? I am not experienced in ASP/Javascript as this project was forced on me so I apologize if this is a simple question but I am honestly stumped.Note- Moving to ASP.Net is out of the question. Please do not suggest this.
 
Back
Top