In a nutshell, the CombineAndMinify package contains two
components:
An adapter for the ASP.NET Head control
When you use runat=“server” in
your head tag, ASP.NET represents the head of your page as an HtmlHead control.
ASP.NET allows you to determine how each control is converted to HTML by
writing a so called adapter. Adapters were originally introduced to allow
developers to generate browser specific code for a given control, but here it
is used to rework the head section of your page.
The adapter is used to replace the tags that load individual
JavaScript and CSS files by tags that load the combined files. If you
configured the CombineAndMinify package to insert version ids in image urls or to
remove white space, the adapter goes through the rest of the page to make that
happen as well.
An HTTP Handler to process JavaScript, CSS
and image files
ASP.NET allows you to write HTTP Handler to do your own
processing of for example JavaScript files. The HTTP Handler included in the
CombineAndMinify package is used to combine and minify JavaScript and CSS
files. It caches the resulting files to save CPU cycles. Using file
dependencies, the cache entries are invalidated the moment any of the files are
updated, so you never serve outdated files.
When you choose to insert version ids in image urls, the
HTTP Handler is also used to strip the version ids out of incoming requests for
images and to serve the images themselves. It also generates the HTTP response
header to allow the browser to cache the image for up to a year.