How can I get the contents of a file using JS, while letting the file be cached by the browser?
One possible way is to make that file a .js
and let it be var SuperVar = 'BASE64-ENCODED-CONTENT'
(base64 to escape special chars), but access and maintenance of the real contents would become indeed hard. I am trying to have normal files after all.
As the files are in size of 1-100 KB and of an unlimited quantity, so is localStorage
not an option (will run out of space).
Have tried with <iframe>
. Browsers parse .html
files somewhat fine. Files need to begin with <html>
else they get wrapped in a <pre>
tag. By other filetypes IE creates an <object>
and offers the file for download.
The point is for JS to work with the same file contents on multiple page loads without downloading them every time.