Z
Z
Zubastik_12018-04-01 01:32:22
PHP
Zubastik_1, 2018-04-01 01:32:22

Have I built simple caching on the server side correctly?

My page is taking a long time to load. A lot of data needs to be requested and processed in the function. Decided to cache. The question is, did I do it right. I've never dealt with this problem before so I need some advice.
I decided to create a separate file in which I write the result of data processing - as an array. Now it remains only to read this array, the problem is solved and the page is loaded instantly.
But there is a question - is this method correct. And yet - what if I need to reset the cache every hour? Delete the file by cron, or you can somehow check the lifetime of the file, or somehow clean it up periodically. A little unclear moment. Thanks to everyone who helps.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Syomov, 2018-04-01
@Zubastik_1

Can be rebuilt by crown.
You can check the lifetime by getting the file modification date/time using php.net/manual/en/function.filemtime.php and comparing it with the current one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question