Showing posts with label silly. Show all posts
Showing posts with label silly. Show all posts

Wednesday, March 28, 2012

Why POST is slower than GET?

Sorry, my question can be silly and a little OT, but I'm really stuck on it...I'm performing some tests with AJAX, actually I'm not using a particular framework or some already written Javascript code. The test is just a simple HTML page that sends (one after the other) 10 requests to another page (in the same site). I'm writing out the time elapsed between the request and the response of every one. When I try this page on my local web server I get very fast responses (more or less 0.01 seconds), with both IE7 or FF2. When I do the same test from another machine (in the same network, and the network has not problems of traffic) I have totally different results. If the page is performing a GET to the server the requests are very, very fast with boht IE7 and FF2. But if I change the GET to a POST (with very few bytes of data) FF2 because much slower (0.25 seconds) and IE7...I don't know...on some machines is still very fast, but on others is as slow as FF2. I can't understand when and why?!? I tried with IE7 on XP (fast), IE6 on XP (fast), IE7 on Vista (some fast and others slow)...there are too many variables, I'm really stuck and I can't understand the difference between these machines. The security parameters seems to be the same, I tried to change them at once...

Please, help me

Cold

This is a great article about why HTTP Post is more expensive than GET. Basically it queries twice and sends more bytes over the wire.

http://msmvps.com/blogs/omar/archive/2006/09/22/Atlas-2_3A00_-HTTP-POST-is-slower-and-it_2700_s-default-in-Atlas.aspx


Thank you very much for your reply. The problem is I'm not using any framework at all and all the requests I'm doing I have written in Javascript code by myself. I checked the code many times, but I couldn't find any problems on it. And I don't have the problem of the double request, as I'm sending just one POST request with the body togheter. And, even if I found a reason for the POST to be slower than the GET, I could not understand why in some machine every request is slow and in others they are so fast (using IE)! There should be some reason, but until now I didn't find any...


I don't understand what about the article doesn't apply to your situation. Basically

1) the browser waits for the server to respond "100 Continue" before the form is submitted. There is no such delay for GET requests.

and 2) the data itself contains additional info such as content types and etc. There are actually 2 requests going on for each POST, and the actual data is twice as long. It's nothing to do with you actually manually sending 2 requests.



This can be true using Atlas, but I'm actually monitoring the requests using Fiddler, and I don't have 2 requests! I have just one request, with the body I have specified on the send() method. I don't have any of the behaviours that the article is talking about. There is just an HTTP request (with method POST) and the resposte to the request, nothing more!

Hope this help to understand my problem...

Cold

Monday, March 26, 2012

Will calling .click() fire an updatepanel Trigger?

This might seem a bit silly but...

Basically, I have a javascript function which calls the .click() method of a button, this button resides outside of any UpdatePanels

This button is also set as a trigger for one of my UpdatePanel controls.

My problem is, the button click runs fine, the server side click event fires ok and rebinds some data for a GridView which is inside the UpdatePanel, but the UpdatePanel does not update its contents.

Do you have to physically click the button with your mouse to cause the Trigger? Or should the programmatic javascript call to click() work?

No will not cause it trigger, you need a postback for that, not a javascript call


You cantrigger an UpdatePanel refresh from the client side, using __doPostBack().

Hi

The programmatic javascript call to click() should work, you must do something wrong.

Look this sample:

<%@. Page Language="C#" %>

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<link href="http://links.10026.com/?link=StyleSheet.css" mce_href="StyleSheet.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
var styleToSelect;
function onOk() {
$get('Paragraph1').className = styleToSelect;
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<p id="Paragraph1">
GetContentFillerTextGetContentFillerTextGetContentFillerTextGetContentFillerText</p>
<br />
<ajaxToolkit:Accordion ID="Accordion1" runat="server" ContentCssClass="grey" FadeTransitions="false"
FramesPerSecond="25" TransitionDuration="250" HeaderCssClass="dimgreen" EnableViewState="true">
<Panes>
<ajaxToolkit:AccordionPane runat="server" ID="PaneOne">
<Header>
AccordionPane0
</Header>
<Content>
<a href="http://links.10026.com/?link=javascript:return false" onclick="javascript: LinkButton1.click()">Click here to change
the paragraph style</a>

</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>
<div style="visibility: hidden">
<asp:LinkButton ID="LinkButton1" runat="server" Text="Click here to change the paragraph style" /></div>
<asp:Panel ID="Panel1" runat="server" Style="display: none" CssClass="modalPopup">
<asp:Panel ID="Panel3" runat="server" Style="cursor: move; background-color: #DDDDDD;
border: solid 1px Gray; color: Black">
<div>
<p>
Choose the paragraph style you would like:</p>
</div>
</asp:Panel>
<div>
<p>
<input type="radio" name="Radio" id="RadioA" checked="checked" onclick="styleToSelect = 'sampleStyleA';" />
<label for="RadioA" class="sampleStyleA" style="padding: 3px;">
Sample paragraph text</label>
</p>
<p>
<input type="radio" name="Radio" id="RadioB" onclick="styleToSelect = 'sampleStyleB';" />
<label for="RadioB" class="sampleStyleB" style="padding: 3px;">
Sample paragraph text</label>
</p>
<p>
<input type="radio" name="Radio" id="RadioC" onclick="styleToSelect = 'sampleStyleC';" />
<label for="RadioC" class="sampleStyleC" style="padding: 3px;">
Sample paragraph text</label>
</p>
<p>
<input type="radio" name="Radio" id="RadioD" onclick="styleToSelect = 'sampleStyleD';" />
<label for="RadioD" class="sampleStyleD" style="padding: 3px;">
Sample paragraph text</label>
</p>
<p style="text-align: center;">
<asp:Button ID="OkButton" runat="server" Text="OK" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</p>
</div>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server"TargetControlID="LinkButton1"
PopupControlID="Panel1" BackgroundCssClass="modalBackground" OkControlID="OkButton"
OnOkScript="onOk()" CancelControlID="CancelButton" DropShadow="true" PopupDragHandleControlID="Panel3" />
</div>
</form>
</body>
</html>

Thanks