Is the "cache engine" only for PHP?

I wrote a pretty small skeleton for my web applications and thought that I would also add a little cache for it.

It is pretty simple:

  • If the current page exists as a file in the cache and the file is not too old, read it and exit, rather than rebuild the page

  • If the current page is not cached / outdated, recount the page and save it

However, this is bad:

  • My performance tests with a page containing 40 relatively long messages through a MySQL query say that using the cache it took even more to process one request (1000 tests each)

  • How can this happen?

  • How do I execute a MySQL query, parsing the results for the first time, passing the results to the template, and then repeating the results in the second case faster than checking filemtime()and reading?

  • Should I just delete the full raw-PHP cache and get rid of the availability of some PHP cache like memcached or so?

+3
source share
4 answers

Premature optimization is the root of all evil. If you do not need a cache, do not use a cache.

, , - , , PHP - . , PHP, PHP .

, - memcached APC. APC , ( APC , ), memcached , - (/ )

+2

-

apc mysql ( ), php- apc, , mysql . , . , mysql, .

-, squid, , . , mysql memcache, , mysql, - . , , (ob_start) memcache.

0

, .

- , , .

HTML/PHP, .

-4

Source: https://habr.com/ru/post/1737796/


All Articles