covid19india / covid19india-react

Tracking the impact of COVID-19 in India
https://www.covid19india.org
MIT License
6.86k stars 3.41k forks source link

Every click on page sends request to fetch data #2497

Closed krishhteja closed 3 years ago

krishhteja commented 3 years ago

Describe the bug A clear and concise description of what the bug is. If your issue is regarding an error in the data, it's best reported through this form.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

Not sure if it is expected but any click on page sends 3 requests (data.min.json, timeseries.min.json, log..json). This could be modified to fetch data every 1 hour or so

shuklaayush commented 3 years ago

I think it only fetches data when the tab regains focus. Otherwise, it should fetch only once every ~10mins (which is reasonable). Are you observing something different?

krishhteja commented 3 years ago

Yes. Any click on any part of the page fetches data

shuklaayush commented 3 years ago

Can you share a video/gif?

krishhteja commented 3 years ago

https://user-images.githubusercontent.com/8438143/121646863-6c90bb00-ca9e-11eb-9108-db7b6b515d42.mov

This issue is not reproducible in mac with chrome but very clearly observed in windows with chrome (version 91.0.4472.77)

shuklaayush commented 3 years ago

Weird, I'm guessing it's a browser issue. Anyways, it shouldn't really matter since the files are served from cache so there's no network usage

krishhteja commented 3 years ago

That's great. I was thinking about network load on server side as people tend to click tens of times.

Quick question : What is the point on sending requests when it uses cached data?

shuklaayush commented 3 years ago

Ideally, it should only send requests every 10 minutes or so to check for updated data. We don't want people to manually have to refresh the website to see if there's a data update. The service worker handles the caching part of the requests