Forums

Why is my page so slow?

Hi, this is probably the third time asking this here, but my page seems to load extremely slowly, even though there isn't a lot of code in my Django view.

When I run web vitals from web.dev I get a 57% performance score because the response time of my server is 4.64 seconds. What is blocking? Or what would be the problem?

This is the view:

homepage view

What is p.product here? Is it possible to use .values() instead of .all() there?

Yeah, p is a BestSeller instance and .product is a Product instance. I think I can use .values(), but I don't think the issue is with the code. Other pages take 2-3 seconds to load too. For example, the "About Us" page takes about 3 seconds to load and its only response is the template, no db queries. Do I need to upgrade my server so it has a faster response time?

Could you add some logging to the views to measure where actually the time is being consumed? I looked at your workers' stats and there were only several moments when you got only one idle worker or no available workers at all. You can have a look at this help page which may help with the estimates.

I timed everything and get_navbar was blocking everything. It finds what categories and subcategories of products had products in them (in an n^2 algo, with multiple db queries), find what items were in a user's cart, etc. I wrote this 8 months ago and never looked at it again. After I removed this function, which was running on all pages, the "About Us" page loads in 350ms, instead of 3 seconds. Thanks for the help and sorry about the fuss.

Oh one other question, I have enabled "Force HTTPS" but when I click on the link from the "Web" tab to go to my page, Chrome asks me if I want to continue, because the site does not support HTTPS. I have it also enabled on Cloudflare. Is it a problem on my part? Why does this happen?

It looks like everything is fine now. Maybe your browser had something cached.