can dynamic pages be compressed and given an etag too?
Any ideas? I'm missing Apache quite a lot. Hope someone can help! :)
To enable dynamic compression, use Microsoft Web Platform Installer to ensure that "IIS: Dynamic Content Compression" is installed. Then open up IIS Manager and click on the server (or to a site if you only want to enable this for an individual site, gets stored in web.config under site root so be careful not to overwrite), and go to Compression and ensure "Enable dynamic content compression" is ticked. This is for IIS7, let me know if you want this for IIS6.
For etags on aspx pages add to Page_PreInit (or Page_Init if Master page):
if (Request.Headers["If-None-Match"] == "somekey")
{
Response.StatusCode = (int)System.Net.HttpStatusCode.NotModified;
Response.End();
}
And to Page_Load:
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetETag("somekey");
Where somekey could be the last modified date stored in the database for the page if it's some content management system.
Related
We have an .NET app. After deployment, we noticed that a number of users had to clear their cache in order for the page to work properly.
I was wondering if an IIS app recycling would do the same thing so the users do not need to clear their local cache.
The server provides caching hints to the client in the response to each resource--many websites have different responses depending on the resource type (static files like .js libraries, css and images, versus dynamic results from .asp pages or API calls). You can use Postman or Fiddler or the developer tools in your browser to view the response headers...and then you can control expiration either in the web.config, the global.asax or your individual code file.
For more information see:
https://learn.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/clientcache
https://thedeveloperblog.com/expiration#:~:text=Expiration%20is%20key%20to%20caching%20in%20ASP.NET.%20We,performance%2C%20resulting%20in%20pages%20being%20expired%20much%20sooner.
I have a website which sits on a non-public domain and is delivered via a proxy through on a different domain. We're having some trouble with caching of content - this is an Umbraco site and making changes updates the pages if you hit the domain directly, but not through the proxy.
I've been informed that the proxy honours response headers and setting an eTag would fix the issue. Having looked into this I can see that IIS sets the eTag by default, and I can see this is working on static content i.e. .js, .css files like so:
However, if I visit a page on the site, for example /uk/products/product I don't see the eTag header.
Is this expected behaviour, should it only be working with those static content files or can I set this on the page to tell the proxy that it should recache?
The ETag HTTP response header is an identifier for a specific version of a resource. It lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed. Additionally,etags help prevents simultaneous updates of a resource from overwriting each other ("mid-air collisions").
If the resource at a given URL changes, a new Etag value must be generated.
Static content does not change from request to request. The content that gets returned to the Web browser is always the same. Examples of static content include HTML, JPG, or GIF files.
IIS automatically caches static content (such as HTML pages, images, and style sheets), since these types of content do not change from request to request. IIS also detects changes to the files when you make updates, and IIS flushes the cache as needed.
to enable caching in iis you could use iis output caching feature:
1)open iis manager. select site.
2)select the output caching feature from the middle pane.
3)select edit feature setting from the middle pane.
4)check the enable cache and enable kernel cache box and click ok.
if you want to set the ETag as blank you could also do by adding below code in web.config file:
<httpProtocol>
<customHeaders>
<add name="ETag" value="" />
</customHeaders>
</httpProtocol>
refer this below article for more detail:
Caching
To use or not to use ETag, that is the question.
Configure IIS Output Caching
I've read that IIS after version 7 automatically enables E-tags, however, I ran a Pingdom speed test and the report advised me to enable E-tags. I'm not sure that report is accurate, or the information I read about IIS 7 and newer may not be correct.
I try to make static content compression work for IIS but it's not working. I'm using Windows Server 2012 R2 Standard, and IIS 8.5.9600.16384.
I installed both static and dynamic content compression, and as you can see both are checked:
Also I went to configuration editor, and there I can see that JavaScript should be compressed:
But still I get no Content-Encoding HTTP header field in my response. What should I do?
Could you get dynamic compression work when you deploy a simple webform application in new IIS site?
As Lex said, Enable Failed request tracing would be the best way to troubleshooting this issue.
1.Install failed request tracing in add role and feature->Web Server->health and diagnostics->tracing
2.Open IIS manager->go to your site node->failed request tracing->add..->all content->status code 200->ensure WWW Server/compression has been checked->finish.
3.Edite site tracing->Enable
4.Open log file in C:\inetpub\logs\FailedReqLogFiles\W3SVC and check dynamic compression procedure.
https://blogs.msdn.microsoft.com/benjaminperkins/2016/06/15/lab-4-install-and-configure-failed-request-tracing/
I'm show event log on windows log
The directory specified for caching compressed content C:\Users\Dat_PC\AppData\Local\Temp\iisexpress\IIS Temporary Compressed Files\Clr4IntegratedAppPool is invalid. Static compression is being disabled.
How to fix ? Thanks everyone :(((
Check RouteConfig.cs make sure your route controller name equal to your MVC Controller name is match
Usually it comes as a warning in event viewer. In IIS, static content compression can be enabled in two levels.
site level
IIS level
Site level you don't have an option to change path. But at the IIS level you can enable and change the path as you needed.
Enable/Disable : Click on the root node of IIS. > At the right content panel > Double click on the "Compression" option. > You may change as needed from the check boxes
I'm having quite a hard time figuring out this problem and I need your help. Here's the scenario:
I have a sharepoint 2010 web application on my port 80. This has 2 site collections, the root, and the /sites/official. My problem is: The root site is empty, but in the future it will be my something (I don't know what yet), but my other site collection is ready to go and I already have an Internet address for it.
What I want to do is configure everything in way that I can type http://contoso.com and get as response my sub-site (yes, its a kind of redirect)...
how can I do it? What and where should I configure it?
add content editor webpart on your root site collection and put this javascript in that webpart
<script type="text/javascript">
window.location = "http://contoso.com/sites/official"
</script>
Open IIS manager
Right click on your SharePoint website -> Properties
Go to tab Home Directory
Choose A redirection to a URL
fill the URL for redirection. for example: http://contoso.com/sites/official
Notes:
Make sure to check A Directory below URL entered to avoid redirect loop
Link to another thread might interest the reader - immediate redirect page in sharepoint
Screenshot:
Add alternate access mapping for the sub-site collection from the central administration.
Central Administration > Application Management > Web Applications > Configure alternate access mappings