
wordpress缓存插件里面,存在一些常见的免费与收费插件,它们各类非常多,功能各异但部分类似。它们都具有以下一类通用特性,那就是可以合并多个 css,js,可以生成.html页面和 gzip压缩文件,也可以按照日期及设置的目录或设置的链接生成,可以调整数据库并优化表的碎片,可以使用 cdn或第三方存储网络功能,有的还可以优化图片及生成 .webm之类的,总之不是三言两语能够说明这一切的。下面介绍的这个插件叫作 wp-rocket,正如它的名字一样,中文翻译过来就叫作 wp火箭,够快了吧?它的官方网址是:wp-rocket.me,它是一个收费的插件,正如你所想的,为什么能够收费而不是免费,正因为它的优点,也就是缓存插件里面数一数二,快到你可以抛弃其它所有你正在用的(偶是说缓存类的插件)。
在下载并激活插件后,您就可以在wp rocket设置页面,开启插件的缓存,它可以根据您的需要启用各种选项和配置:

当您生成缓存之后,就可以访问一个页面,无论是前台还是后台的,然后按 f12或 ctrl + u查看页面源代码,当里面见到类似下面的语句时, <!-- This website is like a Rocket, isn't it? Performance optimized by WP Rocket. Learn more: https://wp-rocket.me -->
证明您的页面已经被缓存,插件功能生效:

wp rocket功能
页面缓存:
创建一个超高速缓存加载时,对于改善搜索引擎优化和增加转换。当你打开WP火箭,页面缓存立即激活。
预加载缓存:
因为我们的爬虫模拟预加载缓存访问搜索引擎索引你的网站,是立即改善。
图片异步加载:
只加载的图像作为访问者向下滚动页面,提高页面的加载时间。youtube,facebook、yahoo、google和其他主要网站都使用这种技术。现在你也可以。
静态文件压缩:
WP火箭的重量减少了 html、javascript 和 css文件通过缩小。轻文件意味着更快的加载时间!
开发人员友好:
根据 wordpress wp rocket的代码开发最佳实践。它是干净的,有许多评论和大量的钩子文档,所以开发人员可以很容易地使高级定制。
wp rocket是当前最高效也是最灵活的 wordpress静态缓存插件。可以优化你的js/css文件结构减少多次请求达到优化速度的目的,还集成了图片延迟加载对最求极致加速的用户不错的选择,通过使用这个插件,能使得你的 wordpress博客将显著的提速。
主要特点
- 自动页面缓存
- 为每个访问的地址创建一个超高速缓存文件
- 预加载缓存
- 图片延迟加载
- 数据库清理优化
- 整合cdn
- 静态文件压缩优化合并 js和 css文件
- 通过缩小减少了 html、javascript和 css文件请求,加快加载时间!
- 开发人员可以很容易地使用高级定制与更多强大的优化功能。

上面是官方的功能说明,现在开始写本文的重点,也就是偶写的 wp rocket规则 web.config,相信这个很少有人听过或见过代码,因为确实米有!你可以搜索整个 google.com baidu.com,真的再找不到相关的了,偶也是因为同样的原因,才在半年前自己写了一个能用的规则出来,下面就分享给喜欢这个缓存插件的朋友或开发人员。这个主要是借用了之前写 wp super cache或其它缓存插件的经验,几乎是照搬只是细微的改动了下,哈哈。多的不再叙述,直接上偶的代码。
//wp rocket规则 web.config
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | <!-- BEGIN wp_rocket_cache --> <rule name="WP_Rocket_HTTPS_mobile_gzip" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author|wordpress_logged_in|wp-postpass)_.*$" negate="true"/> <add input="{HTTP_X_WAP_PROFILE}" pattern="^[a-z0-9\"]+"/> <add input="{HTTP_PROFILE}" pattern="^[a-z0-9\"]+"/> <add input="{HTTP_USER_AGENT}" pattern="^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800|w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).*"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip"/> <add input="{HTTPS}" pattern="on"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-mobile-https.html_gzip" matchType="IsFile"/> </conditions> <serverVariables> <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}"/> <set name="HTTP_ACCEPT_ENCODING" value=""/> </serverVariables> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-mobile-https.html_gzip"/> </rule> <!-- SSL in WordPress: How To Move Your WordPress Site to HTTPS? The Definitive Guide --> <rule name="WP_Rocket_HTTPS_mobile" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <add input="{HTTP_X_WAP_PROFILE}" pattern="^[a-z0-9\"]+"/> <add input="{HTTP_PROFILE}" pattern="^[a-z0-9\"]+"/> <add input="{HTTP_USER_AGENT}" pattern="^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800|w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).*"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" negate="true"/> <add input="{HTTPS}" pattern="on"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-mobile-https.html" matchType="IsFile"/> </conditions> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-mobile-https.html"/> </rule> <rule name="WP_Rocket_HTTPS_gzip" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip"/> <add input="{HTTPS}" pattern="on"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-https.html_gzip" matchType="IsFile"/> </conditions> <serverVariables> <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}"/> <set name="HTTP_ACCEPT_ENCODING" value=""/> </serverVariables> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-https.html_gzip"/> </rule> <rule name="WP_Rocket_HTTPS" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" negate="true"/> <add input="{HTTPS}" pattern="on"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-https.html" matchType="IsFile"/> </conditions> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-https.html"/> </rule> <rule name="WP_Rocket_HTTP_gzip" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip"/> <add input="{HTTPS}" pattern="on" negate="true"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index.html_gzip" matchType="IsFile"/> </conditions> <serverVariables> <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}"/> <set name="HTTP_ACCEPT_ENCODING" value=""/> </serverVariables> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index.html_gzip"/> </rule> <rule name="WP_Rocket_HTTP" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <!-- <add input="{WP_ROCKET_BUSY}" pattern="true" negate="true"> --> <add input="{HTTPS}" pattern="on" negate="true"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index.html" matchType="IsFile"/> </conditions> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index.html"/> </rule> <!-- check backup folder if CSS/JS does not exist in primary directory. --> <rule name="Check backup folder if CSS/JS does not exist in primary directory" stopProcessing="true"> <match url="wp-content\/cache\/min\/1\/(.*)"/> <conditions> <add input="{DOCUMENT_ROOT}/wp-content/cache/min/1/{R:1}" matchType="IsFile" negate="true"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/min/backup/{R:1}" matchType="IsFile"/> </conditions> <action type="Rewrite" url="wp-content/cache/min/backup/{R:1}"/> </rule> <!-- old wp rocket rule. --> <!-- <rule name="WP Rocket" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true" /> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true" /> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress|wp-postpass_).*$" negate="true" /> <add input="{WP_ROCKET_BUSY}" pattern="true" negate="true" /> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{HTTP_HOST}/{R:1}index-https.html" matchType="IsFile" /> </conditions> <action type="Rewrite" url="wp-content/cache/wp-rocket/{HTTP_HOST}/{R:1}index-https.html" /> </rule> --> <!-- END wp_rocket_cache --> |
上面是全部偶写的 wp rocket的 web.config规则,下面还是像之前一篇缓存文章那样一一的解释功能。优先级还是按照从底部到顶的原则,越底下的越低,最顶上的优先级最高。
// 大约 2 – 3年前的 wp rocket规则,也就是大概 1.x.x – 2.3.x之间的这类版本,或许也是更早的,但是如果你要使用这规则必须测试。因为偶现在找不到之前版本的插件,之前因为电脑在 14年底坏了块硬盘之后,很多备份已经丢失。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <!-- old wp rocket rule. --> <!-- <rule name="WP Rocket" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true" /> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true" /> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress|wp-postpass_).*$" negate="true" /> <add input="{WP_ROCKET_BUSY}" pattern="true" negate="true" /> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{HTTP_HOST}/{R:1}index-https.html" matchType="IsFile" /> </conditions> <action type="Rewrite" url="wp-content/cache/wp-rocket/{HTTP_HOST}/{R:1}index-https.html" /> </rule> --> |
// 这是一个备份的目录,一般不会存在,很少情况下它才生成目录,就是当原目录无法生成时,至少新版本的插件偶已经再未见过这样的目录产生。但这条规则却不能忽略,放着不会占用你的多少内存。
1 2 3 4 5 6 7 8 9 | <!-- check backup folder if CSS/JS does not exist in primary directory. --> <rule name="Check backup folder if CSS/JS does not exist in primary directory" stopProcessing="true"> <match url="wp-content\/cache\/min\/1\/(.*)"/> <conditions> <add input="{DOCUMENT_ROOT}/wp-content/cache/min/1/{R:1}" matchType="IsFile" negate="true"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/min/backup/{R:1}" matchType="IsFile"/> </conditions> <action type="Rewrite" url="wp-content/cache/min/backup/{R:1}"/> </rule> |
// index主规则和gzip压缩文件的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <rule name="WP_Rocket_HTTP_gzip" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip"/> <add input="{HTTPS}" pattern="on" negate="true"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index.html_gzip" matchType="IsFile"/> </conditions> <serverVariables> <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}"/> <set name="HTTP_ACCEPT_ENCODING" value=""/> </serverVariables> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index.html_gzip"/> </rule> <rule name="WP_Rocket_HTTP" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <!-- <add input="{WP_ROCKET_BUSY}" pattern="true" negate="true"> --> <add input="{HTTPS}" pattern="on" negate="true"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index.html" matchType="IsFile"/> </conditions> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index.html"/> </rule> |
// https规则和压缩 gzip文件的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <rule name="WP_Rocket_HTTPS_gzip" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip"/> <add input="{HTTPS}" pattern="on"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-https.html_gzip" matchType="IsFile"/> </conditions> <serverVariables> <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}"/> <set name="HTTP_ACCEPT_ENCODING" value=""/> </serverVariables> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-https.html_gzip"/> </rule> <rule name="WP_Rocket_HTTPS" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" negate="true"/> <add input="{HTTPS}" pattern="on"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-https.html" matchType="IsFile"/> </conditions> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-https.html"/> </rule> |
// https mobile的规则和压缩 gzip文件的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | <rule name="WP_Rocket_HTTPS_mobile_gzip" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author|wordpress_logged_in|wp-postpass)_.*$" negate="true"/> <add input="{HTTP_X_WAP_PROFILE}" pattern="^[a-z0-9\"]+"/> <add input="{HTTP_PROFILE}" pattern="^[a-z0-9\"]+"/> <add input="{HTTP_USER_AGENT}" pattern="^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800|w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).*"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip"/> <add input="{HTTPS}" pattern="on"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-mobile-https.html_gzip" matchType="IsFile"/> </conditions> <serverVariables> <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}"/> <set name="HTTP_ACCEPT_ENCODING" value=""/> </serverVariables> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-mobile-https.html_gzip"/> </rule> <!-- SSL in WordPress: How To Move Your WordPress Site to HTTPS? The Definitive Guide --> <rule name="WP_Rocket_HTTPS_mobile" stopProcessing="true"> <match url="^(.*)" ignoreCase="true"/> <conditions logicalGrouping="MatchAll"> <add input="{URL}" pattern="^(.*)$"/> <!-- <add input="{URL}" pattern="^/wp-admin/.*" negate="true" /> --> <add input="{REQUEST_METHOD}" pattern="POST" negate="true"/> <add input="{QUERY_STRING}" pattern=".*=.*" negate="true"/> <add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true"/> <add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$" negate="true"/> <add input="{HTTP_X_WAP_PROFILE}" pattern="^[a-z0-9\"]+"/> <add input="{HTTP_PROFILE}" pattern="^[a-z0-9\"]+"/> <add input="{HTTP_USER_AGENT}" pattern="^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800|w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).*"/> <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" negate="true"/> <add input="{HTTPS}" pattern="on"/> <add input="{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-mobile-https.html" matchType="IsFile"/> </conditions> <action type="Rewrite" url="/wp-content/cache/wp-rocket/{SERVER_NAME}/{R:1}/index-mobile-https.html"/> </rule> |
上面这些规则已经说明了它的用法,在 windows iis7.5及以上,你都可以使用它,如果你的插件对应生成了缓存,那么第 1次访问生成静态文件之后,之后再访问就可以省略大量数据库查询工作,从而加快网站前台页面访问的速度,wp rocket有一个预先缓存的功能,就是当你访问首页时,只要主题支持分页,那么它就预先判断并缓存当前第 2页,比如你访问分类栏目时,它就自动生成当前页面和第 2页的缓存文件,比方你访问第 3页,它就先生成第 3页缓存文件,再生成第 4页的,这样的好处是当你访问第 4页时,速度要远快过第 1次访问生成的,因为省略了生成过程产生的时间,故而速度变快,别的插件为什么不提供这样的功能呢,明明也可以做到这点的,难怪 wp rocket这么优秀,确实在很多方面都为站长考虑到了。如果您能够付费的话,那么这款插件将会非常适合。

如果需要测试网站及页面响应速度,您可以浏览以下两个测试站点: