Output Caching On Static Pages?

Jan 28, 2010

Does output caching help boost the performance of asp.net mvc pages that just consist of html, css, images, and javascript?

View 1 Replies


Similar Messages:

Caching - How To Turn Pages Into Static Pages As Part Of The Build

Dec 29, 2010

I have a few pages that are completely static. They only change at build time. But they are expensive to create. For the ones that are kind of expensive to create, I cache them for very long times using the ASP.NET output caching. But for one page, I really want it cached forever and ever or until the the next build.

What is the most expedient way to make this happen? Is there a build in feature that achieves this or a 3rd party tool?

(yeah, for the moment I plan to do the "view source" and copy paste thing, which isn't a very elegant build step)

View 2 Replies

Web Forms :: Browser Output Doesn't Look Like Web Developer Output Using Nested Master Pages And Css Stylesheets

Apr 18, 2010

First off, suggest better ways if you want rather than patch up this code. I am just starting this project and it is first time I have tried to code a web site so anything you suggest is very much welcomed. I have spent the last 2 and 1/2 days trying to find workable answers to this but none I have found and tried seem to fit. If needed I can email screens shots or code. I am trying to construct a website that will have the same main theme throughout as far as the header, navbars sitemap, and footer go. Naturally the content will vary from page to page. I want to use a single master page and css stylesheet for this main theme and I will change the content format as needed per page because each page may vary somewhat.

However, about 15 of the pages will all use the same format for their content and this format will differ from the rest of the site but the format of the main theme will stay the same. So I am trying to create a nested master page to use to format the just the content area for all these pages while retaining the main theme for the header, etc.. I believe I should use a separate css file with the nested master page to handle the formatting of the content areas for these 15 pages. I have code that looks like it works when viewed in web developer but design view but does not work when viewd through a browser (IE, Chrome, Firefox). So far I have the following done in web developer.

If it helps the code and screen shots follow. Master Page called "Parent.master". For all theme throughout site Nested Master Page called "Lab.master". For the 15 like pages Primary stylesheet file for main theme called "StylesheetNew.css" For site theme Secondary stylesheet file to syle the 15 like formatted pages. It is called Labmaster.css Labs.apsx file to use as first of the 15 like pages.
Finally screens shots from web developer and browser. Sorry try as I might I could not capture screenshots and put them into this post. The problem is that web developer shows all the area (many lines high) with gray background and with the XXX text that I want to allocate for content in the 15 pages. Yet all the browser show is one line of text o a white background followed by the footer. It looks like the LabStyleSheet works in Web Developer but not in a browser.

Parent.master
<%@ Master Language="VB" CodeFile="Parent.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]">
<head id="ParentHeader" runat="server">
<title>HX5</title>
<asp:ContentPlaceHolder runat="server" id="headerPlaceHolder" />
<link href="~/StyleSheetNew.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div id="wrapper" >
<div id="Header" >
<table class="hdrtbl1" >
<tr>
<td id="hdrtd1" style="width:175px; height:100px;" >
<img id="logo" alt="Logo" src="../Images/logo.png" style="width: 136px; height: 87px" />
</td>
</tr>
</table >
<table class="hdrtbl2" >
<tr><td id="hdrtbl2td1"><b> Providing Professional Technical, Manangement and Business Solution</b></td></tr>
<tr><td id="hdrtbl2td2"> <b> Services since 2004 </b></td></tr>
<tr> <td id="hdrtbl2td3" align="center" ><img id="rdln" alt="RedLine" style=" height:3px;" src="../Images/RedLine.png" /></td></tr>
<tr><td id="hdrtbl2td4" > <b>Committed to Excellence In All We Do</b></td></tr>
</table>
</div>
<div id="navbardiv">
<ul id="topnav">
<li><a href="../pages/about.aspx" >About Us <img style=" border: none; " src="../Images/arrow-down.gif" /></a>
<!--Subnav Starts Here-->
<span>
<a style="font-weight:lighter; " href="#" >Who We Are </a> |
<a href="#">Locations</a> |
<a href="#">Business Classifications</a> |
<a href="#">Contact Us</a> |
</span>
</li>
<!--Subnav Ends Here-->
<li><a href="../pages/services.aspx">Services <img alt="arrow" style="border: none; " src="../Images/arrow-down.gif" /></a>
<!--Subnav Starts Here-->
<span>
<a style="font-weight:lighter; " href="#" >Capabilities</a> |
</span>
<!--Subnav Ends Here-->
</li>
<li><a href="#">Customers <img style=" border: none; " src="../Images/arrow-down.gif" /></a>
<span>
<a style="font-weight:lighter; " href="#" >Subnav Link</a> |
<a href="#">Customer Locations</a> |
<a href="../pages/labs.aspx">Labs</a> |
</span>
</li>
<li><a href="#">Careers <img style=" border: none; " src="../Images/arrow-down.gif" /></a>
<!--Subnav Starts Here-->
<span>
<a style="font-weight:lighter; " href="#" >Joining the HX5 Team</a> |
<a href="#">Current Opportunities</a> |
</span>
</li>
</ul>
</div>
<div id="subnavbar" >
<!-- <asp:SiteMapPath ID="SiteMapPath" runat="server">
</asp:SiteMapPath> -->
</div>
<div id="topContent" style="border-bottom:solid 1px #191970;">
<table>
<tr><td style="height:30px; width:900px;" >
<asp:ContentPlaceHolder id="TopPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</div>
<!-- <div id="mainContent"> -->
<asp:ContentPlaceHolder id="MainPlaceHolder" runat="server" />
<!-- </div> -->
<!-- <div id="lowerContent"> -->
<asp:ContentPlaceHolder id="LowerPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
<!-- </div> -->
<div id="footerContent" style=" height:50px; width:900px; text-align: right; background-color: #ccc; ">
<span style=" font-family: Arial, Helvetica, sans-serif; font-size: xx-small; font-weight: bold; color: #000080; margin: 30px 20px 0px 0px;"> Copyright 2010 HX5, LLC All rights reserved</span></div>
</div>
</form>
</body>
</html>

View 4 Replies

MVC :: Output Caching For Several Client IP's

Apr 7, 2010

I have a page with outputcache right above the action in a controller class. What I want is to disable this outputcache for myself. Can it be done by IP?

Something like that: [OutputCache(Duration = 60, VaryByParam = "None", IgnoreIP = "100.100.100.100")]

View 6 Replies

C# - How To Implement Caching Of Static Files

Mar 15, 2011

I use a Masterpage (asp.net webforms) on my site and I woluld like to implement caching of some static files, like javascript, css etc.

I've tried adding the following to my page_load (in the masterpage) but when I use Fiddler the static files are still under "no-cache".

protected void Page_Load(object sender, EventArgs e)
{
// Set cache for 1 hour on all computers and servers.
// ... Proxies, browsers, and your server will cache it.
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(new TimeSpan(1, 0, 0));
}

What am i doing wrong here?

View 1 Replies

MVC :: Output Caching And Query Dependency?

Sep 21, 2010

I plan to use output cache for my page and also specify sql dependencyi succeded in doing it the following way

[Code]....

Suppose if i want to implement a dependency on the sql query , i create an sqlcache dependency object and specify the sql command to it.Set the notifications .But how do i add this sqldependency to the output cache?For example: if i need to add a file dependency, i give something like Response.AddFileDependency ("filepath"); is there any similiar command available for sqldependency as well? I'm confused about this because, most of the examples i've looked into, does a cache.insert , which defeats my purpose as it's object caching and not output caching. In a nutshell, is it possible to attach a sqlcachedependency to o/p cache inside the controller action

View 3 Replies

C# - Caching Through HttpContext.Current.Cache Or Just A Static?

Mar 28, 2011

Last night I wrote up my first IHttpModule to do some request processing. I'm using a regular expression to inspect the raw url. The IHttpModule will be called on every request, so it seems reasonable to do some sort of caching of the regular expression object to prevent creation of it on every request.

Now my question... what is better: use the HttpContext.Current.Cache to store the instantiated object or to use a private static Regex in my module?I'm looking forward to the reasons why. Just to clarify: the regex will never change and thus always be the same thing.

View 3 Replies

State Management :: Caching With Static Classes?

Jul 3, 2010

Currently I have my data cached in Datasets in a static class. I was talking to my cousin's husband, who works as a C# developer for our local Telecom company.

Basically, I'm pretty new to ASP.NET and although to me having cached data in a static class makes sense to me, when I talked to him about it, he said there might be a problem when the site goes live, as on a web server more than one instance of the class may be created.

He did say this was a theory, and it was an area he didn't know an awful lot about, so I thought I'd ask some of you ASP.NET gurus to see if what I've done is totally wrong or not.

View 12 Replies

Web Forms :: User Control Output Caching?

Jan 11, 2010

I have a user control (say PricingGrid.ascx) which generates a pricing grid on a given product's page. I pass the user control 2 parameters : currencyId and productId. The user control has output caching specified by

[Code]....

I am adding PricingGrid.ascx to my page programatically, i.e. using LoadControl [URL]If the user changes their currency and refreshes the page, the cached version of their original currency is still showing, until the 60 seconds expires. Is there any way to force the page to check :1) Does a cached version of PricingGrid.ascx with their new currency exist?2) If so, retrieve that version, and if not, create that version.If I output all the keys in the Page.Cache object on PageLoad, I'm not seeing my user control in the output.

View 3 Replies

Output Caching In HTTP Handler And SetValidUntilExpires?

Jun 8, 2010

I'm using output caching in my custom HTTP handler in the following way:

public void ProcessRequest(HttpContext context)
{
TimeSpan freshness = new TimeSpan(0, 0, 0, 60);
context.Response.Cache.SetExpires(DateTime.Now.Add(freshness));
context.Response.Cache.SetMaxAge(freshness);
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetValidUntilExpires(true);
...
}

It works, but the problem is that refreshing the page with F5 leads to page regeneration (instead of cache usage) despite of the last codeline:

context.Response.Cache.SetValidUntilExpires(true);

UPD: Seems like the cause of problem is that HTTP handler response isn't caching on server. The following code works well for web-form, but not for handler:

Response.Cache.SetCacheability(HttpCacheability.Server);

Are there some specifics of the caching the http handler response on server?

View 2 Replies

State Management :: Using SqlCacheDependency With Output Caching?

Apr 9, 2010

Iam adding SqlCacheDependency programmatically but Iam not able to invalidate the cache.

Iam using the following Output cache directive in the .aspx page

[Code]....

The code in the .aspx.cs file is:

[Code]....

View 1 Replies

MVC - Enabling Caching Of The Compressed Page Output?

Sep 30, 2010

I've seen a number of options for adding GZIP/DEFLATE compression to ASP.Net MVC output, but they all seem to apply the compression on-the-fly.. thus do not take advange of caching the compressed content.

Any solutions for enabling caching of the compressed page output? Preferably in the code, so that the MVC code can check if the page has changed, and ship out the precompressed cached content if not.

This question really could apply to regular asp.net as well.

View 3 Replies

Output Caching A Page Except A User Control In It?

Mar 4, 2011

I have a page which contains a user control. The structure of the page is as shown below:

Incase your not able to see the above image, check it at [URL] Now, apart from the contents of the UserControl, I'd like to cache the entire page. I tried using the OutputCache attribute in the .aspx page, however it caches the contents of the UserControl as well.

View 4 Replies

MVC :: Can't Extend The Output Caching On A Disk For A Partial View

Jan 10, 2011

Output Caching .NET 4 on any view. But I can't extend the output caching (on a disk) for a partial view(RenderAction).

View 1 Replies

MVC :: Output Caching For A View That Is Rendered From Html.RenderPartial

Jul 9, 2010

Ive tried [OutputCache] for a view that is rendered from Html.RenderPartial, but it doesn't work! It works perfectly for 'normal' views.

How do I cache output for partial view?

View 2 Replies

Caching - Controlling Output Cache Memory Usage?

May 17, 2010

I would like to use output caching with WCF Data Services and although there's nothing specifically built in to support caching, there is an OnStartProcessingRequest method that allows me to hook in and set the cacheability of the request using normal ASP.NET mechanisms.

But I am worried about the worker process getting recycled due to excessive memory consumption if large responses are cached. Is there a way to specify an upper limit for the ASP.NET output cache so that if this limit is exceeded, items in the cache will be discarded?

I've seen the caching configuration settings but I get the impression from the documentation that this is for explicit caching via the Cache object since there is a separate outputCacheSettings which has no memory-related attributes.

Here's a code snippet from Scott Hanselman's post that shows how I'm setting the cacheability of the request.

[code]....

View 1 Replies

UserControls - Programmatically Setting Output Caching Duration?

Apr 7, 2010

I want duration to be configurable from Web.config file, so user can alter the output caching after deployment.

For achieving such puropse i need quuivalent C# codebehind snippet of following ASP.NET markup?

<%@ OutputCache Duration="120" VaryByParam="CategoryName" %>

View 2 Replies

C# - Caching W/file Dependency: Static Var Vs. AspNet Cache Vs. Memcached

Sep 29, 2010

TL;DR: Which is likely faster: accessing static local variable, accessing variable stored in HttpRuntime.Cache, or accessing variable stored in memcached?At work, we get about 200,000 page views/day. On our homepage, we display a promotion. This promotion is different for different users, based on their country of origin and language.

All the different promotions are defined in an XML file on each web server. We have 12 web servers all serving the same site with the same XML file. There are about 50 different promotion combinations based on country/language. We imagine we'll never have more than 200 or so (if ever) promotions (combinations) total.

The XML file may be changed at any time, out of release cycle. When it's changed, the new definitions of promotions should immediately change on the live site. Implementing the functionality for this requirement is the responsibility of another developer and I.

Originally, I wrote the code so that the contents of the XML file were parsed and then stored in a static member of a class. A FileSystemWatcher monitored changes to the file, and whenever the file was changed, the XML would be reloaded/reparsed and the static member would be updated with the new contents. Seemed like a solid, simple solution to keeping the in-memory dictionary of promotions current with the XML file. (Each server doing this indepedently with its local copy of the XML file; all XML files are the same and change at the same time.)

The other developer I was working holds a Sr. position and decided that this was no good. Instead, we should store all the promotions in each server's HttpContext.Current.Cache with a CacheDependency file dependency that automatically monitored file changes, expunging the cached promotions when the file changed. While I liked that we no longer had to use a FileSystemWatcher, I worried a little that grabbing the promotions from the volitile cache instead of a static class member would be less performant.

(Care to comment on this concern? I already gave up trying to advocate not switching to HttpRuntime.Cache.)

Later, after we began using HttpRuntime.Cache, we adopted memcached with Enyim as our .NET interface for other business problems (e.g. search results). When we did that, this Sr. Developer decided we should be using memcached instead of the HttpRuntime (HttpContext) Cache for storing promotions. Higher-ups said "yeah, sounds good", and gave him a dedicated server with memcached just for these promotions. Now he's currently implementing the changes to use memcached instead.

I'm skeptical that this is a good decision. Instead of staying in-process and grabbing this promotion data from the HttpRuntime.Cache, we're now opening a socket to a network memcached server and transmitting its value to our web server.This has to be less performant, right? Even if the cache is memcached. (I haven't had the chance to compile any performance metrics yet.)On top of that, he's going to have to engineer his own file dependency solution over memcached since it doesn't provide such a facility.

Wouldn't my original design be best? Does this strike you as overengineering? Is HttpRuntime.Cache caching or memcached caching even necessary?

View 2 Replies

Web Forms :: Output Caching Doesn't Work With Rout Handler

Apr 22, 2010

I am trying to use output caching on my .net pages but it is not working when I use Route handlers to redirect request to actual page, but it works when I call the page directly.

also one more weird thing is that when I am debugging and using .net instance of IIS http://localhost:64293/test it is working, but when I deploy it and try to call the page it is not caching i.e. http://www.mydomain/test(but it works if I call the page directly)

I am using VS 2010, IIS 6.0, .net Framework 4

aspx page code is :

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.master" Title="Not Found" %>
<%@ OutputCache Duration="300" VaryByParam="*" Location ="Server" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
litPageTitle.Text = "<br/>Datetime: " + DateTime.UtcNow.ToString();
}
</script>

my global.asax.cs code is

public static void RegisterRoutes(RouteCollection routes)

View 2 Replies

Running IIS7 In Classic Mode Does Affect MVC Output Caching

Feb 25, 2010

I have a need to run an application in classic mode for backwards compatibility with a specific application, and am trying to understand what kind of impact that will have on the performance of an MVC application that is running on the site. If we put a few static file maps (for .js, .css, .png, etc) above the ASP.NET wildcard map to reduce the amount of processing by the ASP.NET handler, will we be approaching the integrated mode in terms of performance?

The thing i'm primarily concerned with is any effect this might have on output caching. I understand that integrated mode might (?) allow for the output cache to handle non ASP.NET content, but that isn't really a concern. We're more interested in ensuring that the MVC application has full use of the output cache. Empirically i've found that the two configurations operate on par when things go well, but if the page references resources that are not available, the integrated mode tends to fail much more quickly than the classic mode (e.g. 500 ms vs 10 seconds), reducing 'hang time' on the page load.

View 1 Replies

Caching In .net - Error Like "An Object Reference Is Required For Non Static Field?

Feb 9, 2011

I m having a webService.

In that I m using Caching.

I have wrote following code to store datatable in cache.

using System.Web.Caching;

Cache.Insert("dt", dt, null, DateTime.Now.AddHours(1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null);


It give me error like "An object Reference is required for non static field.

View 2 Replies

Render Output To String - Response.Flush Breaking Page Caching

Feb 3, 2010

I have some code that is used to replace certain page output with other text. The way I accomplish this is by setting the Response.Filter to a Stream, Flushing the Response, and then reading that Stream back into a string. From there I can manipulate the string and output the resulting code. You can see the basic code for this over at [URL] However, I noticed that Page Caching no longer works after the first Response.Flush call.

I put together a simple ASP.NET WebApp as an example. I have a Default.aspx with an @OutputCache set for 30 seconds. All this does is output DateTime.Now.ToLongTimeString(). I override Render. If I do a Response.Flush (even after the base.Render) the page does not get cached. This is regardless of any programmatic cacheability that I set. So it seems that Response.Flush completely undermines any page caching in use. Why is this?

extra credit: is there a way to accomplish what I want (render output to a string) that will not result in Page Cache getting bypassed?

ASPX Page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestCacheVsFlush._Default" %>
<%@ OutputCache Duration="30" VaryByParam="none" %>
<%= DateTime.Now.ToLongTimeString() %>

Code-behind (Page is Cached):
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
}
Code-behind (Page is not cached):
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Response.Flush();
}
Code-behind (Page still is not cached):
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Response.Cache.SetCacheability(HttpCacheability.Server);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(30));
Response.Flush();
}

View 1 Replies

Web Forms :: Preventing Caching Of Web Pages?

Jan 28, 2011

I am relatively new to ASP.NET and have searched the Internet to find guidance in preventing caching of web pages (in the latest versions of IE, Firefox, Chrome and Safari). Based on my search, I found a lot of conflicting/confusing info. As best as I can tell, it appears that I need to add the following 3 lines to the <head> section of my .aspx files:

[Code]....

if the aforementioned lines are correct and if all 3 lines are necessary? I have tried using different combinations of the 3 lines, but I get conflicting results (i.e., sometimes the page is cached and sometimes it's not).

View 2 Replies

C# - Client Caching On Authenticated Pages?

Dec 9, 2010

Our web app currently under development has authentication on all the pages.

We can deny a user access to any particular page but have found that if a user had previously opened the page that they can still access the page via the url. [Even if they log out and log in]

Assuming that the page is coming from client cache [Ctrl F5 in IE kicks in the proper authentication behavior or clearing the client cache]

A lot depends on how we have implemented the authentication but a quick fix on our side would be from within the admin section where we deny access to certain pages that we expire client cache for that page.

Is there a way to do this programmatically.

This would mean that client caching would continue to work as normal for all other users that still had access to the page in question.

View 1 Replies

Web Forms :: Re: Master Pages And XMLDataSource Caching ?

Mar 31, 2010

I have a master page that hosts a user control to load my menus from the database depending on the user logged in.So when ever a user logs in, the menu list corresponding to him is loaded into the XMLDatasource that is the Data source for the menus.Following is the code:

[Code]....

The problem is if I log out as one user and Login as another, the XML Data source is not invalidating the cache... and is loading the same values again ..Further I even noticed that the program flow control is not transfered to the LoadMenus.ascx control at times and the page is loaded with out having to go through the control flow of all the controls on the master page. i am not sure how to force the control to pass through a single control.I have set the EnableCaching to false on the xml data source.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved