views:

82

answers:

1

I'm using JSF 1.2 with Richfaces, and for every ajax request, the server is sending back the response, whichi is good, but it also contains all the links to the javascript files. I want to improve the performance so I just want the <body> to be returned, because all the javascript files are already loaded in the browser when the user logs in (my app is not restful). How can i do that?

Thanks

This is an example of a response to reRender an image when clicking a button.

<?xml version="1.0"?>
<html lang="nl_NL" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/basic_both.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/extended_both.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" media="rich-extended-skinning" rel="stylesheet" type="text/css" /><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalcss/page.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.PrototypeScript.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.AjaxScript.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.ImageCacheScript.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/browser_info.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/ajax4jsf/javascript/scripts/form.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/tabPanel.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalcss/tabPanel.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/jquery/jquery.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/jquery.utils.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/json/json-mini.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg.ajax4jsf.javascript.DnDScript.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/utils.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/json/json-dom.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/dnd/dnd-common.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/dnd/dnd-dropzone.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/form.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/script/controlUtils.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/common-scrollable-data-table.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/extended-data-table.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/drag-indicator.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/ext-dt-drag-indicator.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/ext-dt-simple-draggable.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/ext-dt-simple-dropzone.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/dragIndicator.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalcss/extendedDataTable.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/menu.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/context-menu.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/available.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/menu.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalcss/menucomponents.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/tooltip.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/tooltip.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/datascroller.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalcss/datascroller.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/modalPanel.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/modalPanelBorders.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/modalPanel.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/tiny_mce/tiny_mce_src.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/editor.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalcss/editor.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/events.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/scriptaculous/effects.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/JQuerySpinBtn.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/calendar.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalorg/richfaces/renderkit/html/css/calendar.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/panelbar.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalcss/panelbar.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/comboboxUtils.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/utils.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/inplaceinputstyles.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finalscripts/inplaceinput.js.xhtml" type="text/javascript">
</script><link class="component" href="/eyeprevent/a4j/s/3_3_3.Finalcss/inplaceinput.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.xhtml" rel="stylesheet" type="text/css" /><script src="/eyeprevent/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/skinning.js.xhtml" type="text/javascript">
</script><script src="/eyeprevent/a4j/g/3_3_3.Finaljquery.js.xhtml" type="text/javascript">
</script></head>
<body>
<img id="j_id305:supportImage" src="/eyeprevent/image/os-ir-central.jpg" width="50%" />
<meta name="Ajax-Update-Ids" content="j_id305:supportImage" />
<span id="ajax-view-state"><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id24" autocomplete="off" />
</span><meta id="Ajax-Response" name="Ajax-Response" content="true" />
<meta name="Ajax-Update-Ids" content="j_id305:supportImage" />
<span id="ajax-view-state"><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id24" autocomplete="off" />
</span><meta id="Ajax-Response" name="Ajax-Response" content="true" />
</body>
</html>

And this is the code that generated it:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"&gt;
<ui:composition>
<h:form>

    <h:panelGrid columns="1">
    <a4j:region>
        <h:graphicImage id="supportImage" value="#{user.support.imagePath}" rendered="#{user.support.imageLoaded}" width="50%" />
        </a4j:region>
        <h:panelGroup>

<a4j:commandButton action="#{user.support.acceptImage}" value="YES" reRender="supportImage"/>
<a4j:commandButton action="#{user.support.rejectImage}" value="NO" reRender="supportImage"/>


        </h:panelGroup>
    </h:panelGrid>
    </h:form>
</ui:composition>
</html>
+1  A: 

You have certain control over those (scripts and css) by two context params. See here.

I'd suggest that you make a Filter that sets a long time cache for all .js and .css files. Thus you won't have any performance issues.

Bozho