---
title: "XDOC的缓存模式"
author: "xdoc"
date: "2016-03-13T11:49:40Z"
tags: []
categories: ["Web前端"]
slug: "xdoc"
draft: false
lastmod: "2016-03-13T11:50:27Z"
id: 2282486
url: "https://xdoc.iteye.com/blog/2282486"
---

XDOC的运行（&\_func=run）和转换（&\_func=to）支持缓存模式，方法是增加缓存参数（&\_cache=1），\_cache可以是任意的字符串，不同字符串代表不同的缓存。

在缓存模式下，XDOC会将请求结果进行缓存，下次有相同请求时，直接将结果返回。

这种模式在相同请求，结果相同的情况下，能大大提升性能和并发量。

举例：

[http://www.xdocin.com/10001.xdoc?\_format=png](http://www.xdocin.com/10001.xdoc?_format=png)

这个请求在服务器端处理大约需要200毫秒，如果使用缓存模式，处理时间为1毫秒

[http://www.xdocin.com/10001.xdoc?\_format=png&\_cache=1](http://www.xdocin.com/10001.xdoc?_format=png&_cache=1)

![](http://dl2.iteye.com/upload/attachment/0115/7433/57474700-dc7e-38ed-9de4-d8702e14bf3f.png)