Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Municipality links take long to do anything #640

Open
LudwikJaniuk opened this issue Jun 10, 2024 · 1 comment
Open

Municipality links take long to do anything #640

LudwikJaniuk opened this issue Jun 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@LudwikJaniuk
Copy link
Contributor

LudwikJaniuk commented Jun 10, 2024

In the list of all municipalities, each municipality name is a link, but there is a delay when you click it. You only see something happen after 1-2 seconds (on my machine)

To Reproduce
image
Click on a municiaplity name (clearing caches might make a difference) and notice that it takes a long time from the click to something actually happening. For me it's 1-2 seconds.

Expected behavior
I expected to directly get some feedback that I had clicked, e.g. seeing the new page start to load.

Additional context
Based on a comment from @Greenheart:

Kanske för att det tog lång tid att ladda kommunsidorna efter att de klickats? Det kommer nog bli snabbare när vi förbättrar hur vi laddar in data osv.

This might be because it takes a long time for the municipality page to load. Reducing that time could certainly improve this. However, IMO the navigation should happen immediately, and not wait for any loading to happen.

@LudwikJaniuk LudwikJaniuk added the bug Something isn't working label Jun 10, 2024
@Greenheart
Copy link
Collaborator

Greenheart commented Jun 10, 2024

I think this is caused by several factors, but here are my main ideas of how to speed up the navigation:

  • We have a severe caching bug that could be easily fixed: Invalid cache time for ONE_WEEK_MS #634
  • SSR (Server side rendering) for municipality pages, fetching dynamic data (primarily getting the municipality shield from wikidata). All other data is static and won't need to change more often than we make git commits. Thus we could statically pre-render most pages (e.g. fetching data from the wikidata API during build time/deployment), and then make the SSR only responsible for handling redirects.
  • Another thing is that SSR on Vercel is run by temporary Node.js functions that need, which are removed from memory when there have not been any requests for a while. This is commonly referred to as "cold starts". Since we're using the Next.js pages router, we could try option 6 from this list to try to improve cold start performance: https://vercel.com/guides/how-can-i-improve-serverless-function-lambda-cold-start-performance-on-vercel "Setting bundlePagesExternals to true under the experimental flag". This should likely happen in the next.config.js file.

It probably won't be worth making major changes for the existing site though, but we'll keep this in mind for the new site. This is also one of the reasons to move away from Next.js and React to reduce both the code and data needed to show the webpage. I expect to see good improvements in this area in the coming months :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants