Tuesday, April 9, 2019

Internet Explorer returns Response Code 304 (Not Modified) when using XMLHttpRequest

If you attempt to make AJAX callusing XMLHttpRequest from Internet Explorer the browser evaluates server'sresponse as 304 (Not Modified) even if the content was changed.
This is caused by advanced caching optimizations used by Internet Explorer.

This usually happens when suitelet or client script uploads data intoNetSuite and then tries to re-download them.

Alternatesolution:
The simplest solution is to add useless parameter with uniquevalue, e.g. current timestamp which forces Internet Explorer to re-download thecontent everytime.
Below is a sample code used to download content of a suitelet with unique identifier:

var xmlhttp = new XMLHttpRequest();var timestamp = new Date().getTime();var url = 'https://system.netsuite.com/'+    'app/site/hosting/scriptlet.nl?script=1&deploy=1&' +    timestamp=' + timestamp;xmlhttp.open("GET", url, true);xmlhttp.send();

No comments:

Post a Comment