Blogger

投诉/举报!>>

Blog
more...
photo album
more...
video
more...
Home >> 01 Erotic stories>> Regarding ASP.NET page caching
Blogger:aspnet 2023-06-22 23:55:33

Add Favorites

cancel Favorites

Regarding ASP.NET page caching 

    page views:1  Publication date:2023-06-22 23:55:33  
1. ASPX Page Caching: Using ASPX page caching is very simple. Just add the declaration `<%@ OutputCache Duration="60" VaryByParam="none" %>` at the top of the ASPX page. This will cache the entire page content. The ASP.NET code and data source within the page will not be executed during the caching period; instead, the cached page content will be directly output. Page caching applies to all visitors to this page. Therefore, the pressure on the database is the same whether there are 10,000 visitors, one visit, or 1 million visits. `
Duration="60"` specifies the cache time as 60 seconds, which can be set according to your needs. After this time, the cache expires, and each subsequent page will be cached for another 60 seconds, and so on. `VaryByParam="none"` means setting a cache without parameters (caching with parameters will be discussed below). However, for some pages with parameters, such as news content pages (e.g., for the ViewNews.aspx page, which won't automatically read `?id=1`), if the above setting is used, the first news item seen will be cached because `?id=2`, `?id=3` are just different parameters of the page. To allow different news items to be cached separately, `VaryByParam="id"` can be set to cache different `id` parameters individually. If there are multiple specific cache parameters, separate the parameter names with semicolons, for example, `VaryByParam="id;number"`. If you want different query strings to create different caches, set `VaryByParam="*"`. In general, setting `*` is sufficient. These two parameters are required and cannot be omitted. Another important parameter is `DiskCacheable="true|false"`, which means whether to put the cache on the hard drive. If set to false, the cached data will be put in memory. Here's something to note: if the page data is small, you can put the cached data in memory. If the data is large, it's best to put it on the hard drive; otherwise, it will consume a lot of memory and affect server performance. If you cache the data on the hard drive, remember to set the Duration="" value to a relatively large value, such as Duration="3600". If it's set too small, the server will write data to the hard drive too frequently, which will actually reduce performance. If you cache the data in memory, don't set the Duration" value too long. Of course, you'll have to experiment to find out the optimal duration.
2. Disable IE Caching. Imagine a page named New.aspx. Upon the first visit by a client, a new New.aspx file is created in the Internet Temporary Files folder. If the data in New.aspx is modified and the page is visited again, IE doesn't update the data; instead, it opens the page from the first visit! IE automatically (by default) uses the existing New.aspx file in the Internet Temporary Files folder instead of downloading a new New.aspx. How can we make IE automatically download a new New.aspx, like reloading the page after clicking the refresh button? The first solution: Client-side settings: Internet Options → General → Temporary Files settings → Check every time this page is visited. It's best to delete temporary files during this setting. This method allows the client to configure their browser. If the client forgets to configure this, the new page will never be downloaded locally. What will the client think? ("It must be the program's fault!") Furthermore, since others access your page, their browsers are controlled by them, so this method is generally not suitable for solving this type of problem. The second solution: Let the program automatically download the page! This method effectively prevents the page from being saved to the Internet temporary folder; instead, the browser downloads the page every time it's accessed. This is achieved by adding `Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);` to the `Page_Load` event in the `New.aspx` code. Without this line, the page file will appear in the Internet temporary folder; with it, it will not. However, if the .aspx file contains image files or JavaScript files, they will still be downloaded to the Internet temporary folder.
3. Disabling page caching when opening an ASPX page using the `ShowModalDialog()` function in JavaScript: Method 1: First, create an HTML page containing an iframe. The iframe's `src` attribute should be the ASPX page. Then, `ShowModalDialog()` should call this HTML page, not the original ASPX page, thus avoiding caching issues. Method 2: In the `Page_load()` method of the ASPX page, add the line `Response.expires = -1;`. This immediately expires the page, eliminating the need for an outer HTML page.
4. Data source caching : Set `ObjectDataSource.CacheDuration` (caching time: seconds) and `EnableCaching=true`. This way, the method specified by `SelectMethod` will only be called to execute the database query every specified `CacheDuration` time interval; otherwise, cached data will be returned directly. Fixed-time caching is suitable for frequently accessed pages such as the homepage and article list pages, but not for post viewing pages. For example, if there are 1 million posts, and each post is cached for a fixed hour, and 100,000 posts are viewed within that hour, then 100,000 posts would need to be cached, consuming a lot of memory. Even rare, frequently accessed posts are cached for an hour, further consuming memory. In this case, a "sliding window" strategy can be used. For example, a post can be cached for 10 minutes. If it is accessed within 10 minutes, the cache expiration time is changed to 10 minutes after the access, and so on. This way, frequently accessed posts can be "cached long-term," while infrequently accessed posts will not occupy the cache for an extended period due to occasional access. Setting method: Data source: `CacheExpirationPolicy="Sliding"`

URL 1:https://www.sexlove5.com/htmlBlog/62526.html

URL 2:/Blog.aspx?id=62526&aspx=1

Last access time:

Previous Page : How to make several masturbation tools

Next Page :

增加   


comment        Open a new window to view comments