简体   繁体   中英

Asp.net prefetch strategy?

In the header of /pages/dashboard/default.aspx I have included the following:

<link rel="prefetch" href="/pages/agent/statistics/">
<link rel="prefetch" href="/pages/agent/statistics/transactions/">
<link rel="prefetch" href="/pages/agent/consumer/">
<link rel="prefetch" href="/pages/agent/account/">
<link rel="prefetch" href="/pages/feedback/">
<link rel="prefetch" href="/pages/contact/">
<link rel="prefetch" href="/pages/agent/cancel-order/">
<link rel="prefetch" href="/pages/agent/resources/">
<link rel="prefetch" href="/pages/user/preferences/">
<link rel="prefetch" href="/pages/agent/profile/">
<link rel="prefetch" href="/pages/agent/statistics/webservices/">
<link rel="prefetch" href="/pages/agent/statistics/webservices/log/">
<link rel="prefetch" href="/pages/agent/statistics/webservices/error-log/">
<link rel="prefetch" href="/pages/user/download-data/?data-type=Transactions">
<link rel="prefetch" href="/pages/help/">
<link rel="prefetch" href="/pages/agent/resources/">
<link rel="prefetch" href="/pages/about/">

Doing so has meant navigation away from the homepage (/pages/dashboard/default.aspx) for a fresh user has become much faster. All of those links point to the default.aspx page of each folder.

However when testing, I sit at the homepage for a minute to make sure all prefetch pages have time to load.

I am thinking of moving all those prefetch links to the ASP.NET master page, which all of those pages use. So if a fresh user is at the homepage only for a few seconds, the subsequent page can continue loading the prefetch pages.

Is this a better strategy? Or would it tax the server too much, repeatedly requesting aspx pages, which I assume are not cached though their png/jpeg, css and JavaScript resources are?

By prefetching all of these pages, you are multiplying your server traffic, by loading pages which may not be visited by the user. Whether or not this is OK is a development decision you will need to make, and it is a tradeoff between having higher site responsiveness and requiring more server power. It is up to you if you want each user to have a multiplied impact on server utilization.

Each prefetch performs it's own http request, which will require the server to process each request and run your aspx page. Moving the prefetches to your master page will do nothing aside from limit duplication of code, as each page still has to be processed by the server the same as if the user visited that page directly.

If you still decide to prefetch everything, I would recommend placing your prefetch links in your master page, as you only would have to place them in one file.

EDIT:

One other major drawback is that depending on the scope of the pages being prefetched, if there is dynamic data on those pages, the user may see stale data as your browser would be displaying the prefetched version. There may be mechanisms in browsers to prevent this, but this is something I would research.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM