sEcho makes caching difficult - any ideas?
sEcho makes caching difficult - any ideas?
rasmusvhansen
Posts: 4Questions: 0Answers: 0
I have a site where the datatables are redrawn every 5 seconds, thus calling the server.
However to save bandwidth and processing time, I have overriden the fnServerData function so it uses the isModified functionality of jquery.ajax (http://api.jquery.com/jQuery.ajax/)
This causes jquery to send the If-Not-Modified header which the server uses to send a 304 if nothing has been modified.
For components where I just use plain jquery ajax call this works fine.
The problem is that when datatables makes the call, it appends the sEcho=x to the url thus changing the url every time. When jQuery tries to look up the etag of the previous query it does not find anything as the url has changed (sEcho=2), and thus the server will send a 200 status code and the full dataset instead of a 304 and no data.
Is there any good workaround for this?
However to save bandwidth and processing time, I have overriden the fnServerData function so it uses the isModified functionality of jquery.ajax (http://api.jquery.com/jQuery.ajax/)
This causes jquery to send the If-Not-Modified header which the server uses to send a 304 if nothing has been modified.
For components where I just use plain jquery ajax call this works fine.
The problem is that when datatables makes the call, it appends the sEcho=x to the url thus changing the url every time. When jQuery tries to look up the etag of the previous query it does not find anything as the url has changed (sEcho=2), and thus the server will send a 200 status code and the full dataset instead of a 304 and no data.
Is there any good workaround for this?
This discussion has been closed.
Replies
If you don't think that will ever happen, then just remove sEcho - or use fnServerParams to delete it from the parameters being sent to the server.
Allan