This is my first time setting up a web server using nginx/gunicorn so if there is anything obvious on why my TTFB is so high I apoligize.
According to gtmetrix.com my TTFB is 1.4s:
In my own testing, my TTFB was around ~1.3s.
I am confused on why it's so high, even though I enabled Brotli, Caching (Static and Media files), Http2, I enabled html minifier, and so I don't know why. My server is a 2GB CPU on Digital Ocean in NYC (close to where I am), so the location is not the problem. I have checked this stack overflow question, but removing the django-htmlmin package still had a high ttfb. My django view on this page is just:
@minified_response
def home(request):
context = {
'posts': Post.objects.all()
}
return render(request, 'blog/home.html', context)
I think this is a simple query, and I don't expect the TTFB to be so high just for this get query. Is it a problem with my database (right now I am using sqlite)? If you need my any other file or thing to help me debug, just tell me.
Also, according to this article by Cloudflare, my TTFB is high because
At CloudFlare we make extensive use of nginx and while investigating TTFB came across a significant difference in TTFB from nginx when compression is or is not used. Gzip compression of web pages greatly reduces the time it takes a web page to download, but the compression itself has a cost. That cost causes TTFB to be greater even though the complete download is quicker.
So I tried to remove Brotli, but the TTFB was still fairly high, and disabling gzip in the Nginx conf file did not help the TTFB.
Description: Nginx-Gunicorn Server using Digitalocean NYC 2GB CPU On Django (sqlite database)
Edit: I stopped using Cloudflare because there were some issues I was having with it.