What does Cache mean in PHP Script?

In microprocessor, cache mean the ram that is sitting right on the chip dice. It is faster to fetch data from this ram and execute because it probably less clock cycles to fetch.

But what does cache mean in PHP Script?

PHP cache is not the same as microprocessor cache. It does not mean to serve page out of memory directly also so there is no interaction with hard drive and hence faster load time. For example, you.

Caching mean to save the output of a script file such as PHP and store it either in memory or to a file. So the next time the server gets a request, the server does not have to execute the request, but merely fetch the contents from the cache file. That way you will be a lot faster load time and minimum time out errors. This of course has disadvantage that the contents of the page will not be the most current. But this is negligible disadvantage keeping in mind the server load is less and customers are served pages a lot faster!

Memory Cache in PHP

You can serve page or contents directly from memory as well. That I think will be the fast server pages. To do this one can use

file_get_contents() and

where you read the file contents once. When a new request comes in, you make sure the files contents exists, if it does you dump the memory contents. This is great if you have a long list in dropdown list that are update via ajax.

For more info check stackoverflow question on memory cache in php

This entry was posted in Software Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s