Thursday 11 June 2015

Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING



Fix ‘Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING’ error on Chrome


Laravel is a great PHP framework and sometimes you might want to use it to power a website on a shared/cloud hosting service such as Rackspace Cloud Sites instead of a hosting service like Pagodabox which is better suited for hosting web apps. I certainly tried doing this when I set up a website powered by Laravel on my cloud site. 
Nevertheless,  even after setting everything up properly I encountered some very mysterious, and very annoying behavior using the Google Chrome browser that drove me nuts because my web pages only partially loaded and the JavaScript didn’t seem to fully execute code that was supposed to run on page load.
Naturally, I opened the Google Chrome browser developer console panel and found this rather strange looking error being logged:  failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
Frankly, I’m not entirely sure what it means even after Googling around for a solution and if you do know what it means I’d love to hear it in the comments. Nevertheless, after trying a few things I stumbled upon the solution of how to fix the problem across a couple of forum posts. It turns out that sometimes the Xcache PHP extension can sometimes cause this error  and that disabling it locally within the .htaccess file will fix the problem.
Sure enough,  I checked the output of a phpinfo() statement on a PHP script and found the Xcache module installed an enabled.  All I needed to do after determining this PHP extension was installed then was to disable Xcache within the .htaccess  file which is done by using php_flag values and adding them to your .htaccess file like so:
After doing this,  dumping the cache on the browser and reloading the page the error went away,  the page loaded normally and the JavaScript executed as expected. 
you can also write below code on your page 
ini_set(‘xcache.size’, 0);
ini_set(‘xcache.cacher’, ‘off’);
ini_set(‘xcache.stat’, ‘off’);