PHP Cache: How to Cache XML file in php

Cache is important terminology for website performance. The cache is playing very important role to improve the performance of web application.
For example when we are accessing web service and method is accessing data very frequently. The web method response does not change frequently.

At that point, if we are accessing each time web service, it’s very costly in terms of website performance.
At that time we will keep an XML copy of response in the cache folder and use it again and again until response will not change. Now our mind has a question on how to identify the response or file has been changed.
You Can also checkout other tutorials of PHP Cache,

There are two method to control cache expiration:

  1. Set expiry date time of file from cache folder.
  2. File dependent caching(compare file created time of cache file as well as source file).

Below is code to create cache file with fixed expiry datetime.

How To Use PHP Cache Method in HTML file