Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving TTFB for ASP.NET Websites

enter image description hereTrying to figure out why my website is so slow, it's an asp.net empty template using a bootstrap theme. Not using any database or Entity Framework so I am at a loss as to why a simple asp.net website can be so slow.

It seems to be the TTFB (Time to First Byte) is reaching upwards of 15-20 seconds. Sometimes the site is fast but often after some time the site will slow down, my understanding being that IIS is suspending the app pool.

The challenge is I am using Host4Asp and GoDaddy hosting, both have this issue and I can't access IIS to configure it as it's a shared hosting. I created the same website in PHP and it loads instantly, everytime.

I've implemented caching in webconfig and use the CacheOutput attribute on all my controller actions.

<system.webServer>
  <staticContent>
    <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
  </staticContent>
  <urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true" />
  <httpProtocol>
    <customHeaders>
      <add name="Cache-Control" value="public" />
    </customHeaders>
  </httpProtocol>
</system.webServer>

So the question is how do you improve the TTFB of an asp.net website comparable in performance when you have limited access to IIS and you're using a shared host. Surely asp.net is expecting every developer to have a high performance VPS or dedicated server.

I've made a repo on GitHub containing the full solution code if it helps. https://github.com/devfunkd/zenwire

like image 438
devfunkd Avatar asked Oct 31 '22 10:10

devfunkd


1 Answers

Hosting services will typically put your website into sleep mode if no one visits for a while. This might have something to do with it since you noted that the slow-down is only occasional, and improves on your local machine.

like image 72
tim Avatar answered Nov 15 '22 06:11

tim