I know browsers will send an if-modified-since header (with timestamp), to keep an updated cache of css
and js
files.
So, I've run into an issue with loading some random css and js files, for the first time, when a specific page loads.
I'm loading one specific page with jQuery's html()
API.
In a nutshell, I'm simply replacing a nice portion of my current index.html
with snippet.html
(nothing that jquery can't handle)
The catch is I'm including some js
and css
files with snippet.html
Watching my browser load the files, and watching my apache request logs, I clearly see hit and miss requests with these files inside snippet.html
snippet.html
<script type="text/javascript" src="/js/scripts/lib1.js"></script>
<script type="text/javascript" src="/js/scripts/lib2.js"></script>
<link type="text/css" rel="stylesheet" href="/styles/libs.css"/>
<table>
<tr>
<td>Whatever I do here</td>
</tr>
</table>
index.html
<html>
<head>......</head>
<div id="loadshippets"> <!-- later, load snippet.html into here --></div>
</html>
If I hard-refresh my browsers, the libraries load fine and dandy.
However, if I clear my cache and I attempt to load snippet.html
into the <div id="loadshippets">
I run into the same problem.
All I can deduce is that the html()
API has limitations with browsers.
I can always load those libaries inside index.html
, but I'm looking to understand this outcome first. (I may load random libraries later on, and not want them part of the general package)
Anyone see why my lib1.js
, lib2.js
, and libs.css
would be ignored by the browsers?
(tested in Chrome and FF)
If it helps, I noticed in FF's Error Console this message appear:
can't load xregexp twice in the same frame