Caching Css And .js Files?
Dec 5, 2010
I want to use caching technique for .js,.css and images( to avoid round trips and to improve performance of page load) .So, on IIS 7 using Http Response Header, i set Content Expriation to 7 days.Now, on browser its caching which is avoiding round trips for static content ...which is good sign.Now, i modified one of the .js file and i deployed that .js file on server and due to caching my new code is not reflecting on client machines .So i tried lot of ways and here is what i tried after deployment of new .js file After deployment of new .js file
1) I manually delete all the browser cache(cookies,urls,forms,page content etc) on internet explorer
2) used ctrl + f5 to get refresh
3) again on IIS i went back Http Response Header section and set Content Expriation to never
4) stopped the website and restarted
5) on web.config file tried this only
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
6) Also tried to set this on .aspx page
<HTML>
<HEAD>
<TITLE>---</TITLE>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</HEAD>
<BODY>
7) tried to set this on .aspx.cs file
<% Response.CacheControl = "no-cache" %>>
<% Response.AddHeader "Pragma", "no-cache" %>
<% Response.Expires = -1 %>
My target browser is IE.None of them worked,Finally i renamed my .js file to different file name and changed code to make use of that new .js file ..but no luck on this too .Because what i set intially for 7 days still my client machine remembers that.
How do i tell IIS server to refresh cached content code , when some thing got changde on .js or .cssfiles?
View 1 Replies
Similar Messages:
Feb 1, 2011
i recently made a website and have uploaded it to a hosting server. After i had completed the website i noticed that i never added in any expiration onto the files/images plus that i dont know how to do this outside of IIS. As i dont have access to the IIS on the server i need a way of embeding code to set a short exportaion on the images and xml files cached. whats the best way of doing this?
View 5 Replies
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
Apr 26, 2010
i have some javascripts file which i need those to be chached for my website. also can i GZIP javascript files?
View 2 Replies
Nov 30, 2010
i want ot clear the browser caching xml files as i am not abel to load the newly edited xml file
View 4 Replies
Jul 28, 2010
I have an ASP.NET master page which references a #include file as follows:
<!--#include virtual="/includes/scripts.inc"-->
I have modified the file /includes/scripts.inc but the changes do not show up in pages. What needs to be done so modifications will be reflected? I need to avoid the following: restarting the server restarting IIS modifying web.config (doesn't appear to have any effect)
pretty much anything that causes the app domain to restart Any other options? Is there a setting which affects how long IIS caches #include files?
View 4 Replies
Mar 18, 2010
My asp mvc site is not caching content or script files. How do I get it to cache such?
View 1 Replies
Mar 15, 2011
I have gotten confused about how page caching works in ASP.NET. Suppose a user has navigated to "home.aspx" on my website and say I release a new version of that page to the server and the user subsequently navigates to that page, he will get the updated version, is that correct? Is there ever a case where I need to be concerned that the user is NOT getting the latest version of a page(or code-behind) file? The reason I am confused is that quite sometime ago, I found the following code to put in my Page_load event to prevent page caching:
[Code]....
But the more I think about it, I cannot remember the rationale behind this. Whenever I do a release and subsequently visit my site, there is a noticable delay as ASP recompiles. So now I am wondering why the above "no caching" code would be needed or when it is appropriate to use.
View 1 Replies
Mar 4, 2011
At some point in the last month, two web application projects that I've been working on have stopped showing updates to aspx and ascx files until IIS is restarted, or the website they belong to is reset. This seems to be very random and I can't find any reason in the web.config sections that would cause this change. What are some good places to look for a source to this issue?Current caching parts of web.config: Removing the outputCacheProfile and restarting IIS made no difference.
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="ClientResourceCache" location="None" enabled="true" duration="3600" varyByParam="*" varyByContentEncoding="gzip;deflate"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
Commening out the staticConent and restarting also made no difference
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00">
</clientCache>
</staticContent>
<caching>
<profiles>
<add extension=".gif" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".png" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".js" policy="DontCache" kernelCachePolicy="DontCache" duration="00:01:00" location="Any" />
<add extension=".css" policy="DontCache" kernelCachePolicy="DontCache" duration="00:01:00" location="Any" />
<add extension=".jpg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
<add extension=".jpeg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
</profiles>
</caching>
We've also tried adding .ascx and .aspx extensions with CacheUntilChange which made no difference. Other sites with these same settings aren't having the issue. Edit: Originally this state that there also was no update when the project was built, I haven't personally been able to confirm that issue but was told by another developer that was occurring.
View 2 Replies
Jun 14, 2010
I have a page with a number of user controls, In one of my user controls I have a button event. I turn on output cache for the user control that has the button and vary by control using the ID property of a hidden field control in the user control. whenever I turn on the output cache my button event doesn't fire.
View 2 Replies
May 15, 2010
how to implement caching in wcf service using System.Web.Caching
View 2 Replies
Feb 24, 2011
I manage a large asp.net site which has previously been converted from static html site to asp.net. For several reasons (mainly SEO) we decided not to rename all the files to .aspx back when we originally converted the site. This was very easy to do by simply adding the buildProvider and httpHandler to the web.config.
<buildProviders>
<add extension=".html" type="System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
<httpHandlers>
<add path="*.html" verb="*" type="System.Web.UI.PageHandlerFactory"/>
</httpHandlers>
Now I am upgrading the site to use Asp.net WebPages with Razor cshtml files. I can rename all the files if necessary, and use url rewriting to make the urls stay the same, however it would be much easier if I could just configure the web.config to tell it to parse .html files as if they were .cshtml. I have searched around quite a bit, and could not find anything equivalent to the PageHandlerFactory for razor pages. It appears as though it is just an internal mechanism in the .net 4.0 ISAPI handler.
The site is currently running on Windows 2003 server and IIS 6. We will be upgrading to 2008/IIS 7.5 in the near future, but I'd prefer not to wait for that. Is there any way to get the .html files to be parsed by razor as if they were .cshtml files?
View 2 Replies
May 6, 2010
I basically want to do a reverse 'search in all files', so it returns files that don't contain "keyword".Does anyone know how to do this, or the regex used, etc?
View 1 Replies
Oct 13, 2010
I have an application that uses resource files to display items in multiple languages. My app uses quote a lot of javascript and the alerts need to display in the local language. To do this, I have created an http handler which will read the keys and values of the culture-specific resource file and write them to a JSON array which is then embedded in the page in a script tag, the messages can then be accesses using, for exmaple:
Message.Error (en-GB = "Error", fr-FR = "Erreur")
The messages http handler works great in development, however when I run the application on a test server, I get the error: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Resources.Alerts.resources" was correctly embedded or linked into assembly "App_GlobalResources.b0n9j90e" at compile time, or that all the satellite assemblies required are loadable and fully signed. The code that I use to acccess the resource file is:
ResourceManager manager = Resources.Alerts.ResourceManager;
ResourceSet resourceSet= Resources.Alerts.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true);
Where Resources.Alerts is the type that contains my multi-lingual definitions. The build action for the Alerts.resx file is set to "Embedded Resource". Any ideas why this works locally but not on my test server, am I missing something?
View 1 Replies
Jul 1, 2010
I was following the tutorials from this two sites:
http://www.15seconds.com/issue/070104.htm
http://aspnet.4guysfromrolla.com/articles/020404-1.aspx
Following the first site, it had worked but when I´ve moved the pages and files to other folders and set the web.config file on this folder, now it won´t work at all!!!
The file is an *.swf object. I did put the asapi.dll to map the extension on the website root, I´ve put the
[Code]....
on the web.config new folder and on the web.config website´s root.
It won´t work!!! I can access the file directly!!! on the web.config of the folder that contains the file, there is a <deny users="*" /> line.
View 4 Replies
Nov 12, 2010
I am not sure this is the forums but I dont know where to write this and this is an EMERGENCY ::I had windows 2003 server. on C: and I have installed windows 2008 server.I had SQL server installed and all of the database files stored inside c:program filessql server....PROBLEM is that after I installed 2008 server I can see 2 folders of program files one for x86 and the other for 64 bits.
View 2 Replies
Dec 24, 2010
I have a form with 10 file inputs. They can contain 10 random files with random sizes. If I send these files to ASP.NET server with this code:
var count = HttpContext.Current.Request.Files.Count;
var TotalSize = 0;
for (int i = 0; i < count; i++ )
{
HttpPostedFile postedFile = HttpContext.Current.Request.Files.Get(i);
TotalSize += postedFile.ContentLength;
}
And as you can see I didn't save the files on the server, will this code just calculate the summary of files without need to receive the whole file from the client (And therefore it would be very fast)?
View 1 Replies
Jun 5, 2010
i have a production server that does not have ftp access. Possible way to deploy files is connecting with remote desktop client and send files.
As you know this approach is highly hard and time inefficient.
View 4 Replies
Aug 26, 2010
I am trying to open different types of files that I have uploaded on my sql server database. I would like to display all the list of files in Gridview. When user click the link it should open download dialog box and should be able to open its particular applications such as word, excel, browsers etc.
View 3 Replies
Apr 16, 2010
I need to populate a database (SQL Server) with some data from a templated excel document.Here are some approaches:
A) User upload a file.xls or file.csv that the server reads, checks and updates the database (cons:the uploaded file might be too big. file.* needs to be in correct format)
B) User downloads a tool.exe to read and upload file.xls (cons: maintenance of the tool.exe)
C) Use of a web service in excel? (don't know how to do it) but
this article might give you a hint
Which one is the best to use? Are there any others?
View 4 Replies
Apr 15, 2010
I've inherited a bunch of code that has server script inside of .htm files.
On IIS, a handler mapping pumps.Htm pages though the asp.net engine.
Unfortunately, visual studio doesn't notice that they should be treated as code.
Is there any way to make VS treat .Htm files as code/aspx files?
View 3 Replies
Jun 28, 2010
I upgraded my site from asp to asp.net.This means that all of my previous asp files became obsolete.I don't want to lose my Google Ranking of the old pages.
What is the proper way to redirect?I tried to catch all of the old asp pages is my 404 and then to:
if Request.QueryString("aspxerrorpath").contains("index.asp") = true then
Response.Status = "301 Moved Permanently"
Response.AddHeader("Location", "http://www.domain.com/index.aspx")
Response.Redirect("/index.aspx")
end if
but it doesn't catch asp pages, only aspx.
View 3 Replies
Jun 2, 2010
The majority of files in the Temporary ASP.NET File folder for a given application get deleted by ASP.NET following compilation -- .DLL and .PDB files amongst others remain.
Our compiler produces proprietary debug information files which are amongst those that get deleted.
Marking the files read-only prevents this but are there other options available?
View 5 Replies
Apr 4, 2011
Can I Implement Caching in MVC, If so how? I wanted to implement Cache in Controllers
View 2 Replies
Mar 15, 2010
I asked a question a while back on here regarding caching data for a calendar/scheduling web app, and got some good responses. However, I have now decided to change my approach and stat caching the data in javascript. I am directly caching the HTML for each day's column in the calendar grid inside the $('body').data() object, which gives very fast page load times (almost unnoticable). However, problems start to arise when the user requests data that is not yet in the cache. This data is created by the server using an ajax call, so it's asynchronous, and takes about 0.2s per week's data.
My current approach is simply to block for 0.5s when the user requests information from the server, and cache 4 weeks either side in the inital page load (and 1 extra week per page change request), however I doubt this is the optimal method. how to improve the situation? To summarise:
Each week takes 0.2s to retrieve from the server asynchronously. Performance must be as close to real-time as possible. (however the data is not needed to be fully real-time: most appointments are added by the user and so we can re-cache after this) Currently 4 weeks are cached on either side of the inial week loaded: this is not enough. to cache 1 year takes ~ 21s, this is too slow for an initial load.
View 1 Replies