esi icon indicating copy to clipboard operation
esi copied to clipboard

Slowing page down significantly

Open iObject opened this issue 9 years ago • 6 comments

Trying to implement in a Sails.io project but it's taking pages over a minute to render. Any suggestions?

iObject avatar Mar 19 '15 22:03 iObject

This could be HTTP request latency.

But the project could do with some benchmarks. So if you could include a problematic initial page and any external fragments it requires. Then we can add it to the testsuite to monitor performance.

MrSwitch avatar Mar 19 '15 22:03 MrSwitch

The app won't hit a public facing domain for a few weeks due to security policies. I'll see if I can replicate in a fresh sails.io app.

iObject avatar Mar 20 '15 00:03 iObject

The benchmark should not be constrained by network requests.

What i meant was to create a series of files in a spec/mocks directory, i.e.

specs/mock/in.html
specs/mock/includewidget1.html
specs/mock/includewidget2.html
specs/mock/out.html
.... etc

The page "in.html" could be your page which includes ESI markup and is slow to process, the HTTP requests to includeWidget2.html could be stubbed.

This would let us monitor the performance impact of parsing a large page through the ESI module sandboxed from network requests.

MrSwitch avatar Mar 20 '15 02:03 MrSwitch

I'm also facing page slow when using esi includes. My page includes are served from the same box, I see immediate request hits - but sometimes they stall either indefinitely or for long periods of time, before the route is actually hit back.

Page sizes are crazy small.

darrennolan avatar Jun 23 '15 03:06 darrennolan

Actually this might be entirely unrelated, I may have jumped the gun. I'm still investigating the slowdowns on our side. Cheers.

darrennolan avatar Jun 23 '15 03:06 darrennolan

A little late to this but I think the following may be contributing to the issue.

// Overwrite the write function

res.write = function( chunk, encoding ){

    if( !chunk ){
        // dont do anything
        return;
    }

https://github.com/MrSwitch/esi/blob/master/index.js#L103

Here res.write returns early if there is no chunk to be processed. However this should actually end the request, rather than doing nothing since this overrides the default res.write.

The following seems to address it.

if( !chunk ){ return original_end.call( res ); }

@MrSwitch thoughts?

indieisaconcept avatar Oct 26 '16 00:10 indieisaconcept