dataTables.js file not storing in cache / Avoid request with query string
dataTables.js file not storing in cache / Avoid request with query string
Whenever I refresh/load the page, along with the ajax request, datatables file also loads from the server.
Everytime it appends a query string along with the request (http://localhost/js/datatables/jquery.dataTables.min.js?_=1448124952048). So the date dataTables.min.js is not returning from cache and it makes request everytime I reload the page.This does not happen for any other js pages. This costs much in page load time. Is there a way to avoid query string. So that browser can cache js file.
This question has an accepted answers - jump to answer
Answers
Can you show the code you're using to load the js file?
Is it just a
script
? or are you using headJS or requireJS? Is this in something like angular or some type of CMS? Details man! details!.. Preferably a way to replicate the "issue"I highly doubt this is a DataTables related issue though, because this is obviously related to how you're loading the jquery.dataTables.min.js file, not with what the file itself is doing.
That isn't something that DataTables is doing (indeed, DataTables hasn't loaded when you request it!). As jLinux says, this is related to however you are loading the file (or perhaps more probably, whatever loader you are using for the file).
Allan
I want a datatable file only for a particular page (table.html). I called that page inside index.html using jQuery load function. I have called Datatables CSS & JS only inside that table.html .
But I want to know why it does not work if called inside the ajax page.
My code
index.html
table.html
Wait, you're loading the entire file (CSS and JS file tags and all), via AJAX? And your'e wondering why its not working?
Think about it.. For starters.. I believe that the
$().load()
basically just grabs the content of the page, and throws it in whatever the target is.. Meaning the JS/CSS files you include shouldn't work. I mean I haven't ever tried it before, because it's just not the right way to do it.Also, DataTables manages the table through the DOM, and the
$().load()
wont process the jQuery thats on the page and throw it into the DOM.Why are you trying to do it like this anyways? It's definitely a terrible way of accomplishing whatever it is you're trying to accomplish
Sorry for it. I am a beginner.
I thought it would be a bad idea to import it in the index.html since imoprt would be useless if the user does not visit table.html.
Thank u.