C
C
Coffemol2015-12-03 16:05:34
PHP
Coffemol, 2015-12-03 16:05:34

How to do php optimization?

How can you optimize the php code that pulls the protocols through get file so that when the page is updated, the protocols are not pulled out, but they are somehow cached or what can you think of?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nelson, 2015-12-03
@nelson

If we are talking about file_get_contents() with reading data from the URL, and not from a local file, then the easiest option is to save the read data to a local file. Local files are a great caching option.
If you need to keep track of the data lifetime, you can focus on the file modification timestamp - filemtime().
It is highly desirable to use a flock on this file so that several threads do not write to it at the same time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question