redis - java web怎么把页面放到缓存里让nginx直接读取
伊谢尔伦
伊谢尔伦 2017-04-24 09:11:15
0
1
698

想实现这么一个页面静态化的方案:
nginx接受到请求之后先去redis或者memcache中取页面的缓存,如果缓存里没有再取请求action,action里把渲染好的页面缓存起来供下次访问使用。
求解答这个方案有可行性吗,怎么把渲染好的页面存放到缓存里?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
阿神

Nginx has a proxy cache function, which can automatically cache content generated by backends such as Tomcat as static pages, and the expiration time can be set. You can also automatically clear these static caches on the Java side.

Here we take Nginx’s fastcgi cache as an example and use PHP to manually delete the cache:

Nginx里的配置项:
fastcgi_cache_path /png/nginx/1.5.7/ngx_fcgi_cache levels=1:2 keys_zone=WORDPRESS:512m inactive=1d max_size=1g;
以下脚本要清除页面 www.example.com/sample-page 的缓存:
/png/nginx/1.5.7/ngx_fcgi_cache/5/b6/abad4d0ad087b7eecaac98d0a2a08b65
<?php
$dir = '/png/nginx/1.5.7/ngx_fcgi_cache';
$md5 = md5('GET://www.example.com/sample-page');
$cache = $dir.'/'.substr($md5, -1, 1).'/'.substr($md5, -3, 2).'/'.$md5;
@unlink($cache);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template