latitude-dev / latitude

Developer-first embedded analytics

Home Page:https://latitude.so

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Queries data cache is not working properly

abgonzalez93 opened this issue · comments

Environment

  • Node version (node -v): 18.20.2
  • npm version (npm -v): 10.5.2
  • Latitude CLI version (latitude --version): 1.5.0
  • Latitude project version (check latitude.json at the root of your project): 1.1.2
  • OS: Ubuntu 22.04.3
  • Browser: Firefox 125.0.3 & Google Chrome 124.0.6367.119

Actual Behaviour

I am encountering an issue where I am fetching data from an SQL endpoint that I recently modified. However, the browser does not seem to detect the changes even after forcing a browser cache refresh (Ctrl + Shift + R).
When accessing the endpoint via URL directly, the JSON of the new data is retrieved.
Additionally, accessing the endpoint in another browser also reflects the updated data.

Endpoint modified in current browser

imagen

Endpoint JSON with new data

imagen

Endpoint opened in another browser

imagen

👋 Hi! Is this happening in the Latitude project's views, or are you only using Latitude as an API server and building the frontend somewhere else?

I'm using Latitude as an API server (built on WSL2) and fetching data from its endpoints to a Vue3 project

Hmmm. Let's check that your frontend is actually sending requests to the Latitude server, and if the response does contain the actual data.

To do that, open the dev tools in your browser, go to "Network", and look for the fetch requests to the server (filtering for "Fetch" might help finding them). If you find them, you can see contents of both the request and the response.
image

This error could be one of these:

  1. The request has not been sent.
  2. The request has been sent with the wrong parameters.
  3. The request has been sent with the correct parameters, but the response is empty
  4. The request has been sent with the correct parameters and responded with the correct payload, but it is not correctly rendered in the frontend.

If it's either 1, 2 or 4, it seems it has something to do with your Vue application somehow not handling the request properly. Otherwise, if it's the third case, it's an error with Latitude.

I'm getting now the data updated (after a while). Could it be because of the ttl config in source.yml?

imagen

imagen

I see. Yes, the ttl is included in the response header and it seems like the browser caches the response and it seems like currently there is no way from Latitude to invalidate it. I'll open an issue with the specifics and will take a look at it.

Disabling the cache in frontend should update it though. Reloading with Ctrl+Shift+R only works for assets and resources from the webpage that are available in the initial HTML, but not for code-triggered requests like these ones. In order to disable your browser's cache for any request, you must open your dev tools, go to Network, and enable the "disable cache" option.

Issue moved to #381

Thanks for reporting @abgonzalez93! Will take a look asap

@abgonzalez93 this is fixed in the latest release of latitude, as always thanks for reporting 👌🏼