latitude-dev / latitude

Developer-first embedded analytics

Home Page:https://latitude.so

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Browser cache is not handled correctly

csansoon opened this issue · comments

Description

When configuring the TTL in a source or a query, responses will contain a 'Cache-Control' header with this ttl option. In most browsers, this will make it cache the response and not actually send the request to Latitude's server until it has expired.

Main issue

Let's say we have a query with a ttl of 1 day. Requesting this query will return its content and cache the response. If the contents of this query change during the day, requesting the query from the same browser again will not show the updated data, this is expected behaviour. To update it, the user sends a request with the "__force" parameter. This results in two issues:

  • First, this request with the __force parameter, although it does show the updated data, will be cached too. This means that running the request with __force again during the rest of the day won't actually send a force request to the server, since it is just a GET request that is cached in the browser.
  • Additionally, even if we have sent a force request, the original request is still cached, so running it again will still return the original data from the start.

Goal of Feature

  1. Do NOT cache forced requests.
  2. Manage the browser's cache invalidation

Current Solution / Workarounds

The only way to bypass this issue is by disabling browser cache.

solved in #383