Western Mass Hosting's compression Articles

Home / compression

High Performance Wordpress and Server - Part II - Theme Development

High Performance Wordpress and Server - Part II - Theme Development

In part I, I walked you through my server setup to achieve a 1 second load time for my site. It is a Wordpress site, with a custom theme I developed. I gandered at the possibility of by-passing Wordpress's front-end engine, however, I found myself needing some of the built-in…

Why Responsive Web Design Is So Important

Mobile internet browsing is on the rise people!  As of this posting the number of people browsing the internet from a mobile device is up to 18% vs. a declining 82% browsing from a desktop computer.  These numbers are up 6% since this time last year. ~ http://gs.statcounter.com/#mobile_vs_desktop-ww-monthly-201209-201309 What does this…

Speed Up The Web Part III

Boy oh boy, it's about time we go another one of these "Speed Up The Web" articles out here. As with our last article we showed you how you can develop your ASP.Net website and automatically concatenate your scripts and stylesheets. This article will show you a nice and easy…

Cookie Notice

This site utilizes cookies to improve your browsing experience, analyze the type of traffic we receive, and serve up proper content for you. If you wish to continue browsing, you must agree to allow us to set these cookies. If not, please visit another website.

Speed Up The Web Part III

Boy oh boy, it’s about time we go another one of these “Speed Up The Web” articles out here.

As with our last article we showed you how you can develop your ASP.Net website and automatically concatenate your scripts and stylesheets. This article will show you a nice and easy caching mechanism for all your static content. This of course, assumes you do not have use of a CDN (Content Delivery Network).

Now here we have built ourselves a CDN, and for the purposes of this article, we are going to show you how we achieved the caching, and gzipping utilized throughout it.

First and foremost, let’s get the obvious out of the way first:

  • What Is Caching?
  • What Is GZipping?

What Is Caching?

Caching is the temporary storage of frequently accessed data in higher speed media (typically SRAM or RAM) for more efficient retrieval. Web caching stores frequently used objects closer to the client through browser, proxy, or server caches. By storing “fresh” objects closer to your users, you avoid round trips to the origin server, reducing bandwidth consumption, server load, and most importantly, latency.

Caching is not just for static sites, even dynamic sites can benefit from caching. Graphics and multimedia typically don’t change as frequently as (X)HTML files. Graphics that seldom change like logos, headers, and navigation can be given longer expiration times while resources that change more frequently like XHTML and XML files can be given shorter expiration times. By designing your site with caching in mind, you can target different classes of resources to give them different expiration times with only a few lines of code.

Client Caching

Client caching of web sites refers to the storage of CSS, Scripts, Images, HTML, etc on the computer of the person browsing the website.  For the most part this is an extremely efficient method for getting your site to load really fast, by loading these files from their local computer instead of having to download them from the server again.

What happens if the content on the page changes?  Well, other bits of data are sent along the path of the request to the web page you are visiting.  These are called headers, and certain headers can specify if the page, or resource has been changed recently, or even set expiration dates/times for said content.   This will allow client web browsers to download updated versions as they happen.

Proxy Caching

Web proxy caching enables you to store copies of frequently-accessed web objects (such as documents, images, and articles) off server, and then serve this information to users on demand. It improves server performance and frees up network bandwidth to the server for other tasks.

Server Caching

Server caching directly refers to the storage of static/dynamic data in the server memory or hard disk, rather than in the clients web browser’s internal cache.  This usually is just an internal method to cache data for a web application, for example, data is pulled from a database, if this data is unchanged, then there is no need to pull it again, so we store it in the server cache and simply pull it from there.

What Is GZipping?

Gzipping refers to the method of compressing and un-compressing static content sent to the client’s web browser.  Files like minified javascripts, minified css stylesheets, some fonts all benefit greatly from this.  By making the files to send smaller, there is less network traffic when a browser requests a web page.


Now that we got all the nitty gritty details out of the way, how about some code for how we do it?  This is by no means the 100% way to do it, but it is what we have found that works the best for us, and our applications (and I am sure there could be improvements).  Especially our CDN 🙂

This is all done in .Net, and really only consists of a couple classes in our CA.  The main work is done in our web.config file.  So, without any further ado…  here’s the code:

Web.Config

<?xml version="1.0"?>
<configuration>
 <system.runtime.caching>
 <memoryCache>
 <namedCaches>
 <add name="default" cacheMemoryLimitMegabytes="0" physicalMemoryLimitPercentage="25" pollingInterval="00:02:00"/>
 </namedCaches>
 </memoryCache>
 </system.runtime.caching>
 <system.web>
 <pages validateRequest="false" buffer="true"/>
 <httpRuntime executionTimeout="360"
 maxRequestLength="102400"
 useFullyQualifiedRedirectUrl="false"
 minFreeThreads="8"
 minLocalRequestFreeThreads="4"
 appRequestQueueLimit="100"
 requestValidationMode="2.0"
 enableKernelOutputCache="false"/>
 <customErrors mode="Off"/>
 <compilation debug="false" strict="false" explicit="true" targetFramework="4.0"/>
 <httpHandlers>
 <add verb="GET" path="*.*" validate="false" type="CA.ProcessAsync"/>
 </httpHandlers>
 </system.web>
 <system.webServer>
 <validation validateIntegratedModeConfiguration="false"/>
 <modules runAllManagedModulesForAllRequests="true"/>
 <handlers>
 <add name="all" verb="GET" path="*.*" type="CA.ProcessAsync" preCondition="integratedMode"/>
 </handlers>
 </system.webServer>
</configuration>

ProcessAsync.vb

Imports System.Threading.Tasks
Imports System.Web

Public Class ProcessAsync
 Implements IHttpAsyncHandler

 Private Sub DoIt(ByVal context As HttpContext)
 Try
 Dim _file As String, _name As String, _ext As String
 _file = context.Server.MapPath(context.Request.FilePath.Replace(".ashx", ""))
 _name = _file.Substring(_file.LastIndexOf("") + 1)
 _ext = _file.Substring(_file.LastIndexOf(".") + 1)
 With context.Response
 If _ext.Equals("aspx") Then
 Dim handler As Web.IHttpHandler = UI.PageParser.GetCompiledPageInstance(context.Request.Path,
 context.Request.PhysicalPath,
 context)
 context.Server.Transfer(handler, True)
 Else
 .ClearHeaders()
 .AddHeader("Powered By", "o7t.In ~ o7th Web Design")
 Parallel.Invoke(Sub()
 Select Case _ext
 Case "png", "jpg", "jpe", "jpeg", "tif", "tiff", "gif", "bmp",
 "cur", "ico",
 "pdf", "swf",
 "woff"
 Case Else
 Common.GZipOutput(context)
 End Select
 End Sub,
 Sub()
 Common.SetBrowserCache(context)
 End Sub,
 Sub()
 .ContentType = Common.SetContentType(_ext)
 End Sub,
 Sub()
 .AddHeader("Content-Disposition", "inline; filename=" & _name)
 End Sub)
 .WriteFile(_file)
 End If
 End With
 Catch ex As Exception
 End Try
 End Sub

 Private _Delegate As AsyncProcessorDelegate
 Protected Delegate Sub AsyncProcessorDelegate(context As HttpContext)

 Public Function BeginProcessRequest(ByVal context As HttpContext, ByVal cb As AsyncCallback, ByVal extraData As Object) As IAsyncResult Implements IHttpAsyncHandler.BeginProcessRequest
 _Delegate = New AsyncProcessorDelegate(AddressOf ProcessRequest)
 Return _Delegate.BeginInvoke(context, cb, extraData)
 End Function

 Public Sub EndProcessRequest(ByVal result As IAsyncResult) Implements IHttpAsyncHandler.EndProcessRequest
 _Delegate.EndInvoke(result)
 End Sub

 Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
 Get
 Return True
 End Get
 End Property

 Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
 DoIt(context)
 End Sub

End Class

Common.vb

Public Class Common

 Public Shared Sub GZipOutput(ByVal context As Web.HttpContext)
 With context
 If IsGZipSupported(context) Then
 Dim accEncoding As String
 accEncoding = .Request.Headers("Accept-Encoding")
 If accEncoding.Contains("gzip") Then
 .Response.Filter = New System.IO.Compression.GZipStream(.Response.Filter, System.IO.Compression.CompressionMode.Compress)
 .Response.AppendHeader("Content-Encoding", "gzip")
 Else
 .Response.Filter = New System.IO.Compression.DeflateStream(.Response.Filter, System.IO.Compression.CompressionMode.Compress)
 .Response.AppendHeader("Content-Encoding", "deflate")
 End If
 End If
 End With
 End Sub

 Public Shared Sub SetBrowserCache(ByVal context As Web.HttpContext)
 With context.Response
 .AddHeader("Cache-Control", "store, cache")
 .AddHeader("Pragma", "cache")
 .AddHeader("Cache-Control", "max-age=21600")
 .AddHeader("ETag", Date.Now.Ticks)
 .AddHeader("Expires", DateTime.Now.AddYears(1).ToString("ddd, dd MMM yyyy hh:mm:ss") + " GMT")
 .AddHeader("Vary", "Accept-Encoding")
 .Cache.SetVaryByCustom("Accept-Encoding")
 .Cache.SetOmitVaryStar(True)
 .Cache.VaryByParams.IgnoreParams = True
 .Cache.SetAllowResponseInBrowserHistory(True)
 .Cache.SetCacheability(Web.HttpCacheability.Public)
 .Cache.SetValidUntilExpires(True)
 .Cache.SetLastModified(DateTime.Now.AddYears(-1).ToString("ddd, dd MMM yyyy hh:mm:ss") + " GMT")
 .CacheControl = "public" '
 .Expires = 24 * 60 * 366
 .ExpiresAbsolute = DateTime.Now.AddYears(1).ToString("ddd, dd MMM yyyy hh:mm:ss") + " GMT"
 End With
 End Sub

 Public Shared Function SetContentType(ByVal _Ext As String) As String
 Select Case _Ext
 Case "pdf"
 Return "application/pdf"
 Case "rdf"
 Return "application/rdf+xml"
 Case "svg"
 Return "image/svg+xml"
 Case "tif", "tiff"
 Return "image/tiff"
 Case "swf"
 Return "application/x-shockwave-flash"
 Case "png"
 Return "image/png"
 Case "jpg", "jpe", "jpeg"
 Return "image/jpg"
 Case "gif"
 Return "image/gif"
 Case "bmp"
 Return "image/bmp"
 Case "css"
 Return "text/css"
 Case "js"
 Return "text/js"
 Case "atom"
 Return "application/atom+xml"
 Case "xml", "dtd", "xls", "config"
 Return "application/xml"
 Case "txt", "asc"
 Return "text/plain"
 Case "htm", "html", "shtml"
 Return "text/html"
 Case "xhtml", "xht"
 Return "application/xhtml+xml"
 Case "cur"
 Return "image/x-win-bitmap"
 Case "ico"
 Return "image/vnd.microsoft.icon"
 Case "eot"
 Return "application/vnd.ms-fontobject"
 Case "woff"
 Return "application/x-font-woff"
 Case "otf", "ttf"
 Return "application/octet-stream"
 Case Else
 Return "text/html"
 End Select
 End Function

 Private Shared Function IsGZipSupported(ByVal _Context As Web.HttpContext) As Boolean
 Dim accEncoding As String = _Context.Request.Headers("Accept-Encoding")
 If (Not accEncoding Is Nothing) Then
 If (accEncoding.Contains("gzip") Or accEncoding.Contains("deflate")) Then
 Return True
 Else
 Return False
 End If
 Else
 Return False
 End If
 End Function

End Class

Enjoy folks, and thanks for reading!

Our Privacy Policy

Last Updated: June 18th, 2025

Introduction

Western Mass Hosting (“we,” “our,” or “us”) respects the privacy of all individuals and organizations that interact with our services. This Privacy Policy establishes our practices regarding the collection, use, disclosure, and protection of personal information for visitors to our website and clients utilizing our managed hosting and WordPress services. By accessing our website or engaging our services, you acknowledge that you have read and understood this policy in its entirety.

Scope and Applicability

This Privacy Policy governs our handling of information collected through our corporate website and in the course of providing managed hosting, WordPress maintenance, and development services. In accordance with global privacy regulations, we serve as a Data Controller for information related to our business operations and client relationships. When processing data on behalf of our clients through hosted services, we act as a Data Processor under applicable data protection laws.

Information We Collect

We collect various categories of information necessary to provide and improve our services. This includes personal contact and payment details provided during account registration, technical information such as IP addresses and device characteristics for security purposes, and records of communications through support channels. For clients utilizing our hosting services, we may process end-user data stored within client websites, though we do not control or monitor the collection practices of such data.

Purpose and Legal Basis for Processing

We process personal information only when we have proper justification under applicable laws. The primary legal bases for our processing activities include the necessity to fulfill contractual obligations to our clients, our legitimate business interests in maintaining and improving our services, and in limited cases, explicit consent for specific marketing communications. We maintain detailed records of processing activities to demonstrate compliance with legal requirements.

Use of Collected Information

The information we collect serves multiple business purposes. Primarily, we use this data to deliver and maintain reliable hosting services, including server provisioning, performance monitoring, and technical support. We also utilize information for business operations such as billing, customer relationship management, and service improvement initiatives. Security represents another critical use case, where we analyze data to detect and prevent fraudulent activity or unauthorized access to our systems.

Data Sharing and Third-Party Disclosures

We engage with carefully selected third-party service providers to support our operations, including cloud infrastructure providers, payment processors, and customer support platforms. These relationships are governed by strict contractual agreements that mandate appropriate data protection measures. We may disclose information when legally required to comply with court orders, government requests, or to protect our legal rights and the security of our services.

International Data Transfers

As a global service provider, we may transfer and process data in various locations worldwide. When transferring personal data originating from the European Economic Area or other regulated jurisdictions, we implement appropriate safeguards such as Standard Contractual Clauses and rely on adequacy decisions where applicable. Our subprocessors, including AWS Lightsail, maintain robust compliance certifications to ensure the protection of transferred data.

Data Retention Practices

We retain personal information only for as long as necessary to fulfill the purposes outlined in this policy. Client account information is typically maintained for five years following service termination to comply with legal and financial reporting obligations. Backup data associated with hosting services is automatically purged after thirty days, as specified in our Terms of Service. For data processed on behalf of clients, retention periods are determined by the respective client’s policies and instructions.

Security Measures

We implement comprehensive technical and organizational security measures to protect personal information against unauthorized access, alteration, or destruction. Our security program includes network encryption protocols, regular vulnerability assessments, strict access controls, and employee training on data protection best practices. We maintain incident response procedures to address potential security breaches and will notify affected parties where required by law.

Individual Rights

Individuals whose personal data we process may exercise certain rights under applicable privacy laws. These rights may include requesting access to their information, seeking correction of inaccurate data, requesting deletion under specific circumstances, and objecting to particular processing activities. We have established procedures to handle such requests in accordance with legal requirements, typically responding within thirty days of receipt. Requests should be submitted to our designated Data Protection Officer through the contact information provided in this policy.

Cookies and Tracking Technologies

Our website employs various technologies to enhance user experience and analyze site performance. Essential cookies are used for basic functionality and security purposes, while analytics cookies help us understand how visitors interact with our site. Marketing cookies are only deployed with explicit user consent. Visitors can manage cookie preferences through their browser settings or our cookie consent tool.

Policy Updates and Notifications

We periodically review and update this Privacy Policy to reflect changes in our practices or legal obligations. Material changes will be communicated to affected clients through email notifications at least thirty days prior to implementation. Continued use of our services following such notifications constitutes acceptance of the revised policy.

Contact Information

For questions or concerns regarding this Privacy Policy or our privacy practices, please contact our Data Protection Officer at info@westernmasshosting.com or by mail at:

Western Mass Hosting
22 Orlando. St.,
Feeding Hills, MA 01030.

We take all privacy-related inquiries seriously and will respond promptly to legitimate requests. For clients with specific data processing agreements, please reference your contract for any additional terms that may apply to our handling of your data.