Whether redis is required for caching in the following service scenarios - caching

If you are setting up a forum, do you need redis to cache blogs or posts when they are updated frequently? It has been suggested to cache only the structure of the blog/post and then store the text content in the database. What does "blog structure" mean in this context?

Related

Should I use Redis to cache the response of queries?

I have a social app on a Parse Server (Ubuntu) and I need to cache server-side the users' content, like their main feed and chat, in order to speed things up. Is Redis suitable for that kind of caching? If not, what would you recommend?
Also, I was thinking a way to minimize my db reads and I came up with an idea of an up-to-date cache, where I'll have triggers on new post saves and there, I'll be refreshing my cache. Is that a good practice?
Redis can deifnitely be used to cache stuff. Twitter uses (or at least used to) Redis to cache the timeline. This blog post can give you more insight as to how they use it. Lot of good snippets of information for why Redis was chosen.

Understanding web caching (Redis)

I'm working on a web app that receives data from an API provider. Now I need a way to cache the data to save from calling the provider again for the same data.
Then I stumbled on Redis which seems to serve my purpose but I'm not 100% clear about the concept of caching using Redis. I've checked their documentation but I don't really follow what they have to say.
Let's suppose I have just deployed my website to live and I have my first visitor called A. Since A is the first person that visits, my website will request a new set of data over API provider and after a couple seconds, the page will be loaded with the data that A wanted.
My website caches this data to Redis to serve future visitors that will hit the same page.
Now I have my second visitor B.
B hits the same page url as A did and because my website has this data stored in the cache, B is served from the cache and will experience much faster loading time than what A has experienced.
Is my understanding in line with with the concept of web caching?
I always thought of caching as per user basis so my interaction on a website has no influence or whatsoever to other people but Redis seems to work per application basis.
Yes, your understanding of web caching is spot on, but it can get much more complex, depending on your use case. Redis is essentially a key-value store. So, if you want application-level caching, your theoretical key/value pair would look like this:
key: /path/to/my/page
value: <html><...whatever...></html>
If you want user-level caching, your theoretical key would just change slightly:
key: visitorA|/path/to/my/page
value: <html><...whatever...></html>
Make sense? Essentially, there would be a tag in the key to define the user (but it would generally be a hash or something, not a plain-text string).
There are redis client libraries that are written for different web-development frameworks and content-management systems that will define how they handle caching (ie. user-specific or application-specific). If you are writing a custom web app, then you can choose application-level caching or user-level caching and do whatever else you want with caching.

Hippo cms cache method

What kind of cache Hippo cms is using?
I found something about bundle cache on official page, but I don't have idea where information are stored and how get them out.
Main problem is I need synchronize L2cache between a lot of instances of Hippo cms application.
Hippo CMS has caching implemented at several different levels of the overall architecture. It's important to keep in mind that the Hippo stack has 3 main components:
The content repository (backed by an RDBMS)
The Hippo delivery tier (HST)
The Hippo CMS UI
My assumption is that you're probably trying to do this for the delivery part of the application. Let's take a bottom-up approach and see what different types of caching are available.
The content repository caches raw data from the persistence layer in the Bundle Cache. This is an in-memory cache provided by Apache Jackrabbit and its size can be configured in the repository.xml. You can already consider this an L2 Cache if you would compare this to for instance Hibernate, since it's shared by all JCR sessions. You can find more information on how to tune this cache on the corresponding documentation page.
The Hippo delivery tier uses a couple of in-memory model representations derived from repository configuration and four different caches: Binaries Cache, WebFiles Cache, Node Cache and Page Cache.
The Binaries Cache is used to cache static resources that are stored in the content repository, such as PDFs and images. It can be configured to be served from memory or disk. The binaries cache is using Ehcache in the background. More information on how to configure or specify your own cache can be found here.
The WebFiles Cache is used to also cache static resources from the repository, but instead of typically user content like PDFs and images, it is more developer static webapp content.
The Node Cache caches the contents of individual JCR nodes retrieved from the content repository. This includes actual content items (documents) as well as configuration stored in the repository such as web page layouts and URL mappings. The observation pattern is used to invalidate node cache entries when the original node in the repository is modified.
The Page Cache caches complete aggregated pages. This means that web pages can be served directly from cache without any content retrieval and page aggregation as long as no modifications are made to the content and configuration making up the page. Once any of these is modified the delivery tier is notified through observation and invalidates the cached page. Requests arriving while the modified page is being aggregated can be served a stale cache entry to keep response times low. More information can be found here. The page cache is based on ehcache and can be configured through Spring configuration.
As you can see there are several levels of caching available. You have to keep in mind though that if you have multiple Hippo instances running, the caches will be automatically invalidated on all individual instances because of how clustering and cache invalidation works within Hippo, so in the end you might not even need to introduce additional caching.
You can find more information on the performance documentation page.

what are some caches that are responsible for fetching the data on miss?

The book 'architecture of open source software' says that the most common type of global cache in a web application is responsible for fetching the data itself, in case it is missing, as shown on this fixure. This seems different than what I've encountered so far. Most applications I have encountered make the application server responsible for fetching data from the db, and updating the server. At first, I thought the book might be talking about caching proxies, like Varnish, but they cover those in the next section, so that doesn't seem to be the case.
What cache systems actually fetch the data in case of a miss, and how do they know how to interact with the database?
Caching solutions provide read-through/write behind features which enable users to configure a read-through/write-behind provider be implementing some interface and deploying it with cache server. These providers contain logic about how cache server can interact with database to load/save data in database.
On a cache fetch operation if data is not present in cache server, cache loads data from database using configured provider thus avoiding a cache miss.
This way client applications deal cache as only data source and cache itself is responsible for interactions with database. You can read further details in this article by Iqbal Khan.
NCache and TayzGrid are enterprise solutions among many others that provide this feature.

How to ensure Breeze cache is not persisted in local memory

I have a project that I am working where data cannot be cached on the client of certain entity types. Some are Ok, and others are not.
I don't see anything in the documentation or the API that references NOT caching an entity of a particular type, so is there a way to do this to prevent secure information from being cached?
What have I tried?
Nothing... I don't see a way to do this...
Edit
As an alternative, if anyone from IdeaBlade could lend a hand in explaining how and where the caching is saving info and where (if anywhere) that information is persisted it may be helpful in alleviating the need to NOT cache.
Edit 2
Ok no answer, yet, I changed the title -
How can I ensure no sensitive data is persisted in the local memory after the browser has been shut down?
There are two questions here.
How to keep Breeze from holding entities of a type in its in-memory cache.
How prevent caching of entities across browser sessions.
Number 2 first: Breeze in memory cache evaporates when the browser session closes and is not shared across browser sessions. You can arrange for local persistence but that's a conscious decision and some small effort. I don't think you have to worry about that.
If you want to prevent a type from being cached in memory at all (really? Why?) you could write a simple JsonResultsAdapter that zaps the $type parameter for nodes of this entity type and let's the others pass through to the default adapter. Breeze only makes cachable entities out of nodes with a recognized $type. Look that adapter up in the doc.

Resources