When a visitor visits my site while the application is not started, the application will start. For this first visitor, everthing will act a little slow.
This will get worse because i want to use application_start to cache lots of (almost) static data. This is perfect for overall performance, but for the first visitor, the site acts even slower.
Therefore it would make sense to only cache the most necessary items on application_start. A good example would be caching the menu items. I need the top level items on the first request, but the child items can wait a little longer. My submenu contains
subcategories with the amount of articles like "Food and drinks (14 articles)" and is a bit time consuming. But i will need them at some point and i don't want to wait until a user selects a top level item.
So I was wondering if next scenario would work.
1. cache mainmenu items on application_start, for example:
Cache.Insert ("menuitems", menuds)
The cached menu items are now available in cache for all requests, also the first request.
2. Cache submenu items on page_unload (only after the first request) for instance:
If cache("submenuitems") is nothing then
cache.insert("submenuitems",submenuds)
End if
Ok, i left out locking the cache but what do you think?
1. You can visit your site immediately after each new build that is deployed to make sure that you are the one encountering the slowness instead of an actual user.
2. You can try to make your code more efficient so that it does not increase the load time of that first user by a significant amount.
In the same idea as option 1, you may want to create a simple bat file or script that calls your browser and points it to your site, then closes the browser after 20 seconds, or however long. That way, you can just run that script after each new deployment
in order to ensure that you do not have any random users experience "extra" slowness.
sander_aspne...
0 Points
1 Post
Caching stuff on application_start
Aug 17, 2007 12:16 PM|LINK
Hi everyone
When a visitor visits my site while the application is not started, the application will start. For this first visitor, everthing will act a little slow.
This will get worse because i want to use application_start to cache lots of (almost) static data. This is perfect for overall performance, but for the first visitor, the site acts even slower.
Therefore it would make sense to only cache the most necessary items on application_start. A good example would be caching the menu items. I need the top level items on the first request, but the child items can wait a little longer. My submenu contains subcategories with the amount of articles like "Food and drinks (14 articles)" and is a bit time consuming. But i will need them at some point and i don't want to wait until a user selects a top level item.
So I was wondering if next scenario would work.
1. cache mainmenu items on application_start, for example:
The cached menu items are now available in cache for all requests, also the first request.
2. Cache submenu items on page_unload (only after the first request) for instance:
If cache("submenuitems") is nothing then
Ok, i left out locking the cache but what do you think?
EndangeredMa...
Participant
1134 Points
211 Posts
Re: Caching stuff on application_start
Aug 17, 2007 06:13 PM|LINK
You basically have two options that I'm aware of.
1. You can visit your site immediately after each new build that is deployed to make sure that you are the one encountering the slowness instead of an actual user.
2. You can try to make your code more efficient so that it does not increase the load time of that first user by a significant amount.
In the same idea as option 1, you may want to create a simple bat file or script that calls your browser and points it to your site, then closes the browser after 20 seconds, or however long. That way, you can just run that script after each new deployment in order to ensure that you do not have any random users experience "extra" slowness.