file:read-binary performance
Hi, My restxq app is very slow to deliver raw files (css, images, js). For example, the restxq method takes around 600ms to load a png file in my browser when it takes only 2ms in a "direct" or "static" way. --------------------------------------- declare %rest:path("/editions/static/{$project}/{$file=.+}") function max.file:file( $project as xs:string, $file as xs:string ) as item()+ { let $path := file:parent(file:base-dir()) || 'editions/' || $project || '/ui/' || $file return ( web:response-header(map { 'media-type': web:content-type($path) }), file:read-binary($path) ) }; --------------------------------------- Why such a difference? How can I improve it? I am using BaseX 8.3 (war version). Regards, Jérôme -- Jérôme Chauveau - CERTIC-DSI - Campus I Université de Caen Normandie
Hi Jérôme, I just created a new WebApp with your function inside, and I retrieved a 300 kb jpg file. In the browser console view, I could see that it took 18 ms to request it (on localhost), so I guess there must be another reason for this delay. Feel free to provide us with more hints, Christian On Wed, Nov 25, 2015 at 10:57 AM, Jérôme Chauveau <jerome.chauveau@unicaen.fr> wrote:
Hi,
My restxq app is very slow to deliver raw files (css, images, js). For example, the restxq method takes around 600ms to load a png file in my browser when it takes only 2ms in a "direct" or "static" way.
--------------------------------------- declare %rest:path("/editions/static/{$project}/{$file=.+}") function max.file:file( $project as xs:string, $file as xs:string ) as item()+ { let $path := file:parent(file:base-dir()) || 'editions/' || $project || '/ui/' || $file return ( web:response-header(map { 'media-type': web:content-type($path) }), file:read-binary($path) ) }; ---------------------------------------
Why such a difference? How can I improve it?
I am using BaseX 8.3 (war version).
Regards,
Jérôme
-- Jérôme Chauveau - CERTIC-DSI - Campus I Université de Caen Normandie
Hi Christian, thank you for your answer. Shame on me... I did not get the aim of .ignore files! My app' slowness came from my resources (js, css, images) folder (a quite big one) which did not contain a .ignore file. The difference is really impressive. Regards, Jérôme Le 25/11/2015 11:07, Christian Grün a écrit :
Hi Jérôme,
I just created a new WebApp with your function inside, and I retrieved a 300 kb jpg file. In the browser console view, I could see that it took 18 ms to request it (on localhost), so I guess there must be another reason for this delay.
Feel free to provide us with more hints, Christian
On Wed, Nov 25, 2015 at 10:57 AM, Jérôme Chauveau <jerome.chauveau@unicaen.fr> wrote:
Hi,
My restxq app is very slow to deliver raw files (css, images, js). For example, the restxq method takes around 600ms to load a png file in my browser when it takes only 2ms in a "direct" or "static" way.
--------------------------------------- declare %rest:path("/editions/static/{$project}/{$file=.+}") function max.file:file( $project as xs:string, $file as xs:string ) as item()+ { let $path := file:parent(file:base-dir()) || 'editions/' || $project || '/ui/' || $file return ( web:response-header(map { 'media-type': web:content-type($path) }), file:read-binary($path) ) }; ---------------------------------------
Why such a difference? How can I improve it?
I am using BaseX 8.3 (war version).
Regards,
Jérôme
-- Jérôme Chauveau - CERTIC-DSI - Campus I Université de Caen Normandie
-- Jérôme Chauveau - CERTIC-DSI - Campus I Université de Caen Normandie
participants (2)
-
Christian Grün -
Jérôme Chauveau