问题
Here is a hum-dinger of a problem that I have not found an answer for.
I am using the ASP.NET ajax control toolkit controls on a few pages, which by nature want to load script resources via WebResource.axd. This is all well and good for some applications, but each call to WebResource.axd requires an HTTP request. Most pages will pull at least 3 or 4 resources from the WebResource.axd, so this many HTTP requests are issued for each page.
Since having too many HTTP requests will negatively impact performance and user perceptions of performance, I would like to trim that down to 1 HTTP request, if possible.
If I could extract the script from the AXD or configure asp.net ajax to use a script instead of the WebResource, it would really be sweet.
Does anyone know how I can go about accomplishing the end goal while using asp.net ajax? (At this moment another JS AJAX framework is not an option.)
EDIT: Found the solution. This guy is eternally crafty and I will owe him many meals/beer should we ever meet. http://www.codeproject.com/KB/aspnet/fastload.aspx
EDIT: Found another solution -- apparently MS allows you to download the scripts without including the resource dll. All you need to do is include them in the project and set the ScriptPath on the Script Manager.
回答1:
The easy route: Define proper HTTP caching headers. The user agent will sort out multiple requests to the same resource based on them, and you don't have to hack around the problem on the server side.
来源:https://stackoverflow.com/questions/221761/how-do-i-force-asp-net-ajax-to-use-a-script-from-the-fs-and-not-webresource-axd