3
23 Comments

Which cache system do you use? And why?

Hi, everyone I am working on using a cache system for my project, which one should I use, varnish or memcache(it's for db, I know) or what ever you guys used tell about it, and what should I use? And why?

P. S It's a very much dynamic site

Let me know your thoughts!

  1. 6

    Can you give more details about your particular use case/problem that you try to solve? A cache is not a necessity, but something that solves a problem :)

    1. 6

      +1 to this. Don’t fall into the trap of building your ideal architecture before you need it. Use a cache when you actually have scaling issues, not in anticipation of them.

      1. 1

        yep! @jakelazaroff @victorhurdugaci I am sure I need to add cache system, specially to cache DB requests.

        And you can get more details on what am working on here,
        https://www.indiehackers.com/post/what-dont-you-like-about-wordpress-be494d3d07

        I actually discussed with other Indiehackers on what am working on, to get there suggestions! feel free to drop your suggestions too!

        1. 1

          Hi Aryabh,

          We are building something that could help you very much. It's not open to the community yet, but could you please check if it would make sense for you?

          http://www.querycache.com/

          1. 1

            seems!! great! man! I will try to add an integration for your QueryCache in my upcoming cms.

            Check here to know what's the cms I am working on.
            https://www.indiehackers.com/post/what-dont-you-like-about-wordpress-be494d3d07

            1. 1

              That's a nice project you've got there. We are using Wordpress so far, but I'm pretty unsatisfied with that.

              I'll let you know when we open QueryCache, and please let us (Indiehackers) know when your platform is ready as well!

  2. 3

    Redis when project earning allows that and file cache when not :-)

    The first one is scalable and flexible, the second one when the cache is needed anyway, but you don't have the big cache database (like thousands of items).

    1. 1

      Actually I have! haha!! every page checks for site config data for DB and then it generates page. That's why I needed use cache system!

      you can get more details on what am working on here,
      https://www.indiehackers.com/post/what-dont-you-like-about-wordpress-be494d3d07

      I actually discussed with other Indiehackers on what am working on, to get there suggestions! feel free to drop your suggestions too!

      1. 1

        Hey @aryabh, the good thing to store configurations is a PHP file configuration storage. You take your configuration when it changed and put it to the PHP file. Then regenerate your file again when the config is changed. This one is super fast.

        1. 1

          you mean something like environment file? that's not a bad idea! thanks man!

          1. 1

            Yep, try to cache configurations from database in PHP files like that, then include them by require() when you need to read them:

            <?php
            
            return [
              'cached_key1' => 'cached_value1',
              'cached_key2' => 'cached_value2',
            ]; 
            

            You can export configurations like that with var_export() function, and they are working extremely fast — because PHP files are stored in memory by OPcache:
            https://www.php.net/manual/en/function.var-export.php
            https://www.php.net/manual/en/intro.opcache.php

  3. 2

    Redis. Simple, performant, battle-tested, good for a million uses.

    1. 1

      ah! seems like more and more people are using redis ! I might as well use it for DB caching.

  4. 1

    Redis! It's is super cool for things like slow db queries, computationally expensive data. Also it can be used as messsage, job queue. I personally like to use it whenever I need something really fast.

  5. 1

    What problem are you trying to solve?

    1. 1

      As I said the site is very much dynamic, it peaks server load. So I am trying to generate static page for whatever I can and cache requests.

      1. 1

        What do you mean by "very much dynamic"? Dynamic content, by definition, can't be cached very efficiently.

        1. 1

          by very much dynamic, I meant like before it's page is loaded it gets site configurations, that particular page configuration, then user configs ! and some time comments too! that's why I said it's too much dynamic! but this all values barely changes except comments! so if a cache is generated of the page, it will only purges if changes in these values are done. And for comments I was thinking of trying Redis as it was recommended by many in comments, might as well give it a try!

  6. 1

    or just read the stuff in to an internal cache, save it in memory in the program, it will save you a lot of hassle

    1. 1

      great idea! @flipchan I was thinking of saving it to memory.

  7. 1

    Depends on use case. Http caching via Varnish is blazingly fast and IMO the simplest for static content, but comes at the expense that most requests never hit your backend, which means any backend tracking systems you use cannot operate.

    In these cases - or when the content is dynamic - I use Russian doll caching of HTML fragments or expensive data operations via Memcached.

    1. 1

      ah! I see, haven't used Russian Doll. I will try it.

      Thanks @semicolonandsons

  8. 1

    This comment was deleted 4 years ago.

  9. 1

    This comment was deleted 3 years ago.

Trending on Indie Hackers
How I grew a side project to 100k Unique Visitors in 7 days with 0 audience 49 comments Competing with Product Hunt: a month later 33 comments Why do you hate marketing? 29 comments My Top 20 Free Tools That I Use Everyday as an Indie Hacker 18 comments $15k revenues in <4 months as a solopreneur 14 comments Use Your Product 13 comments