Search code examples
javascriptphpvue.jsvue-resource

What kind of data should be cached?


I'm creating an API with "PHP" that get all responses and data from DB I'll use "VueJs" to create the Front-End as SPA and Vue-resource to make http requests, is it better to use PHP or JS to cache and what kind of data should be cached. Database will contain some texts and images only


Solution

  • Why caching is used?

    When a particular resource is requested multiple times, it is often beneficial for developer to cache resources to give response quickly.

    Where is caching used?

    Caching has wide range of applications from system architectures to web software.

    How caching works?

    Cache works by temporarily storing highly requested resource in a fast access location, like RAM, which is much faster than secondary memory.

    Popular caching strategies

    Please have a look at this page

    How to use caching in web applications?

    This question has many solutions, but a popular approach is to use memcached object storage. It stores objects in main memory. The server side code must handle the GET requests in layers, the request must hit the cache layer first, check if the object is in cache. If yes(Hit), send response, else continue serving request from next layer.