S
S
SciFi2015-10-07 08:14:29
PHP
SciFi, 2015-10-07 08:14:29

How to create a graphic widget in PHP? Load?

An example of such an informer is any graphical counter like Yandex.Metrica
. How to make them correctly?
I have several entities in the database. For each of them, a certain X value is calculated several times a day. When requesting: site.ru/informer.php?id=1, I want to display the X value as a picture.
How to do it - I understand perfectly. But how to do it right?
How not to generate a picture each time anew? How to check that this generation is not needed?
One of the ideas is this: each entity has its own picture. The picture has the date it was last modified. When the user contacts me, I check: if the update date X < the date the picture was modified, then we return the old picture. Is this enough or can it be done better?
And the question that should certainly be asked here is: what are the correct headers to set for caching images in the browser?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lyeskin, 2015-10-07
@lyeskin

The value of X will be in what format? How often is this value calculated and what does it depend on?

A
Artem Spiridonov, 2015-10-07
@customtema

The generated image can be saved under the name in the value hash token. If you use, for example, nginx, the load will certainly be reduced.
You can also cache image fragments by constructing output with imagemagick. The latter is written in C++, so it is obviously faster and more economical.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question