Improving the compressibility of your pages

If your server uses compression, then it makes sense to optimize compressibility of your text files. Compression algorithms like repeating content, which puts a premium on consistency:

  • Always specify HTML attributes in the same order. One way to achieve this is to have all your HTML generated by high-level web controls and custom server controls, instead of low-level HTML server controls. This will slightly increase CPU usage, but will give you assured consistency. For example, write the following:
    <asp:Hyperlink runat= server ......>
    

    Instead of the following:

    <a runat="server" .... >
    
  • Likewise, within CSS selectors, write your properties in alphabetical order.
  • Use consistent casing. Use all lowercase for ...

Get ASP.NET Site Performance Secrets now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.