Can nginx implement content-based caching for POST requests?
黄舟
黄舟 2017-05-16 17:29:34
0
1
600

Because it is a webservice and the content of the post is json, the commonly used API interfaces need to be cached. I wonder if it can be done at the nginx layer?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
Ty80

Yes, the working mode of nginx at this time is a response agent, but it is not suitable

First of all, you need to know how you want to cache the content. For example, if the input is the same (same user cookie, same http post parameters), how long will it take for the cached content to expire? To implement such a configuration file, it is almost as simple as writing code, then Why not write it in python or php

Where is the cache stored? Assuming that you have done all the above things with the configuration file, where do you want to put the built-in cache? Disk or memcache, it seems to be a programming job.

If you feel that it is appropriate to use nginx to do these things, please continue. Otherwise, implement it in the code and try to make the nginx configuration file as simple as possible. Use PHP (fastcgi) or python to use memcache for caching, and the efficiency is still the same Quite high, at least a little faster than the cache speed of nginx for reading files. After all, it is a memory operation

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!