You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This NuGet package helps with static .html files. Here's what it does:
Minifies HTML including embedded script and style blocks
FingerPrints references to images, script and css files
Makes it easy to serve static resources from CDNs or cookieless domains
Handles Conditional GET requests (304's)
No code required. It works automatically after installing the NuGet Package.
It works by registering an HTTP Handler that takes over .html files. After
doing the transformations, it output caches the response until the .html file
itself or one of the referenced resources are updated on disk.
To minify the HTML, StaticWebHeper uses WebMarkupMin.Core for the best and
safest minification. You can enable the minification through an appSetting:
<addkey="minify"value="true" />
2. FingerPrinting
FingerPrinting is the process of appending a file version to any referenced
resources. This is important in order to do cache busting, so the resources
can have far-future experication dates.
Take this JavaScript reference:
<scriptsrc="script/menu.js"></script>
The browser will automatically cache scripts/menu.js, so that when you
update the file, the browser will serve the old version from its cache.
To fix that, we need FingerPrinting. With StaticWebHelper the above script
tag will be rendered like this:
The numbers are the DateTime.Ticks of when the file was last changed.
A URL rewrite is automatically being added to the web.config in order
to handle the new URL.
2. CDN or cookieless domain
To serve static files such as images, JavaScript and CSS files from a
CDN or a cookieless domain is good for the performance of any website.
Typically, a sub domain is used to serve static files and with
StaticWebHelper this is now easy to use. Instead of serving our
JavaScript file from /scripts/menu.js we can now easily update the
reference to point to the sub domain/CDN.