I have implemented static page cache (file cache) in my own PHP Framework. can I speed up page loading?

Source: Internet
Author: User
I have implemented static page cache (file cache) in my own PHP Framework. can I speed up page loading? I have implemented static page cache (file cache) in my own PHP Framework. can I speed up page loading?

Reply content:

I have implemented static page cache (file cache) in my own PHP Framework. can I speed up page loading?

Yes, of course, but pay attention to the time when the static cache is output. if the static cache is displayed and the output of the dynamic page is rendered, there are as many program codes as it passes through, there is naturally not much improvement in page loading speed.

If PHP is used to generate a cache, you should add a cache judgment before the controller logic starts. if the judgment is made when the controller renders the template, the performance improvement will not be obvious.

I will describe a method that does not require PHP to participate in cache generation and use. it is definitely more efficient than any cache system that requires PHP to participate.
It is implemented using Nginx.fastcgi_cacheFor example, cache WordPress:

Fastcgi_temp_path/png/nginx/1.5.7/ngx_fcgi_tmp; fastcgi_cache_path/png/nginx/1.5.7/ngx_fcgi_cache levels keys_zone = WORDPRESS: 512 m inactive = 1d max_size = 1g; fastcgi_cache_valid 200 301 302 1d; # cache 1 day (day) fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_cache_key $ request_method: // $ host $ request_uri; location ~ \. Php $ {fastcgi_cache WORDPRESS ;}

PHP only needs to implement the cache deletion function:

PHP sample code purge. php: The following script clears the page GET: // www.example.com/sample-page cache:/png/nginx/1.5.7/ngx_fcgi_cache/5/b6/abad4d0ad087b7eecaac98d0a2a08b65
  

Generally, php frameworks have built-in labels. These built-in labels need to be parsed into native php scripts by the framework. Then it is handed over to cgi for execution. if the cache is generated, the tag parsing process can be avoided, which can naturally increase the speed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.