spee.ch icon indicating copy to clipboard operation
spee.ch copied to clipboard

Plan caching to minimize server load (SSR, etc.)

Open bones7242 opened this issue 8 years ago • 5 comments

Currently spee.ch is not doing any caching (other than what express.js does natively out of the box. Spee.ch should cach rendered versions of pages so it doesn't have to do SSR tasks, MYSQL lookups, etc. repeatedly.

bones7242 avatar Apr 24 '18 20:04 bones7242

One option for caching, using redis: https://www.npmjs.com/package/express-redis-cache

bones7242 avatar May 24 '18 17:05 bones7242

@lyoshenka also mentioned https://varnish-cache.org/ which sits in front of the web server

bones7242 avatar May 24 '18 17:05 bones7242

one issue for caching, raised by @skhameneh, is that SSR of page may need user session data. This is currently solved by serving the site without a logged in guest, and having the client make an api call to update the redux state with any logged in user data.

bones7242 avatar May 24 '18 17:05 bones7242

another issue with caching is that the same url (e.g. https://spee.ch/xyx/doitlive.jpg) could be one of two types of request: (a) a request from a user that wants to view the asset in a web browser, or (b) a direct request for the asset from a page in which the asset is embeded. @lyoshenka suggested redirecting embed requests to a slightly different url (e.g. `https://spee.ch/embed/xyz/doitlive.jpg')

bones7242 avatar May 24 '18 21:05 bones7242

@billbitt cached responses should honor limited header data. Ideally the cache, by default, should only store calls that don't contain session information.

Caches can exist at (some examples):

  1. Thread level
  2. Machine-level (VM/server, separate thread or same-machine redis/memcache)
  3. Cluster level (external Redis, Memcache, etc)
  4. Client-side

skhameneh avatar May 29 '18 04:05 skhameneh