ASP.NET Output caching Location? - c#

I need to know where the files are saved when a page is cached using the following:
<%# OutputCache Duration="60" VaryByParam="None" %>
Because sometimes I need to delete the files to 'reset' the page so I can get the latest data.
EDIT: A second question: does the above line uses the memory of the server to save the cached pages?
Thanks

You could use the RemoveOutputCacheItem method to remove a cached page.
does the above line uses the memory of the server to save the cached pages?
This will depend on the value of the Location attribute. If you set it to Server then it will be stored in memory. If you set it to Client, then the page will be cached on the client browser.

Related

trouble with url not stored in the database

During page loads I append certain parts to my URL like http://myproject.com/Page1.aspx/id=219 to help me with storing some info between postbacks, however I don't want to keep this URL in the database.
So in case someone copies it, and loads it for the first time in their browser, it should be rerouted to http://myproject.com/Page1.aspx
Can this be done and how? Is it good practice?
More context: the id is dependent on temporarily generated controls
Are there better ways? My current http://myproject.com/Page1.aspx/id=219 loads same content as http://myproject.com/Page1.aspx if loaded suddenly with no context
On the contrary loading http://myproject.com/Page1.aspx** first and interacting with the page will lead to http://myproject.com/Page1.aspx/id=219 properly loaded
What about using a cookie, session variable, or browser localstorage to store this data and not send it through the url at all?

Does ASP.NET has a built-in feature to get user history?

I'm looking for a built-in solution to get what pages the user has accessed through my ASP.NET application.
Here is a simple example :
Default.aspx
Page1.aspx
Page2.aspx
Page1.aspx <-- User is here
I want to get latest page before current one which in this example is Page2.aspx.
Maybe Master Page or ViewState could help ?
There is not a "built-in solution".
If you must do this-
If the history is small you could store it in a session.
If bigger, persist to a db.
You could also look into integrating with google analytics.
You could use Request.UrlReferrer to find out the page (or site) that took the user to the current page.
Or Page.PreviousPage which tells you the same info but has some caveats:
When you use the Transfer method or use cross-page posting to transfer
processing from one ASP.NET page to another, the originating page
contains request information that might be required for the
destination page. You can use the PreviousPage property to access that
information. If the current page is being rendered as a result of a
direct request (not a transfer or cross-post from another page), the
PreviousPage property contains null.
However, you only get the previous page. If you want the full history, you will have to enable/implement some sort of tracing in your app.

Loading ASPX markup from database

Let say I have one default.aspx page in local development but in production we have different mark up according to client requirement might be we will not use up-comming.ascx user control on client page but we using on local or using for other client. in short how can load aspx markup from database not .cs code since it is already compiled only change aspx.

Where is cached information stored in ASP.NET?

I am developing a website and I want to implement caching to improve its performance.
If I use
<# OutputCache Duration="20" VaryByParam="None">
where will my page be stored? On the client side or on the server? If it's stored on the client side, where is it stored?
Can I cache a master page?
If you don't specify a location, the Output Cache directive will at least store it on the server. It also allows (via headers) intermediate proxies and clients to cache if they choose to.*
It's up to the consuming client to a) choose whether to respect the cache header and b) where to cache. For most browsers it's usually in "Temporary Internet Files" or some equivalent.
*It's more of a "suggestion" that proxies or clients cache, since either way it's ultimately up to them.
You may checkout the documentation. According to it the default value of the cache location is Any which means:
The output cache can be located on the
browser client (where the request
originated), on a proxy server (or any
other server) participating in the
request, or on the server where the
request was processed. This value
corresponds to the
HttpCacheability.Public enumeration
value
As far as caching the master you cannot put an OutputCache directive to a master page. You could do it programatically by enabling caching in all the content pages.

Does setting HttpCacheability.Public also cache the page on the server?

I have these lines in my global.asax (basically because of Can I add my caching lines to global.asax?)
The thing I want to now understand is whether this code purely adds the HTTP headers to the page or does it also make .Net cache this page on the server for 300 seconds?
Response.Cache.SetExpires(DateTime.Now.AddSeconds(300));
Response.Cache.SetCacheability(HttpCacheability.Public);
Your page will be stored in output cache, too. Are you sure you want to do this for every page on the site?
KB article

Categories

Resources