You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "bettydramit (JIRA)" <ji...@apache.org> on 2013/07/09 18:07:48 UTC
[jira] [Updated] (TS-2008) Cache control with muti suffix
[ https://issues.apache.org/jira/browse/TS-2008?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
bettydramit updated TS-2008:
----------------------------
Description:
配置强制Cache jpeg js 等,需要多条配置
dest_domain=www.test.com suffix=jpeg ttl-in-cache=1m
dest_domain=www.test.com suffix=js ttl-in-cache=1m
现在改为用,分隔后缀
dest_domain=www.test.com suffix=jpeg,js,css,html ttl-in-cache=1m
patch:
diff -Nur ts-3.3.1/proxy/ControlMatcher.cc ts-3.3.1-new/proxy/ControlMatcher.cc
--- ts-3.3.1/proxy/ControlMatcher.cc 2013-03-10 03:44:28.000000000 +0800
+++ ts-3.3.1-new/proxy/ControlMatcher.cc 2013-07-08 22:42:31.568980245 +0800
@@ -44,7 +44,7 @@
#include "P_Cache.h"
#include "P_SplitDNS.h"
#include "congest/Congestion.h"
-
+#include <string>
/****************************************************************
* Place all template instantiations at the bottom of the file
****************************************************************/
@@ -815,6 +815,63 @@
if (file_buf == NULL) {
return 1;
}
+ /* add by reggie */
+ if(strcmp("[CacheControl]",matcher_name) == 0){
+ Debug("reggie-suffix","file_string is begin" );
+ char *strbuffern = NULL;
+ char *strfile_buf = file_buf, *tmpvalue = NULL;
+ char *cp_line[64];
+ int in = 0;
+ char buffer1[128] = {0};
+ char *outer_ptr=NULL;
+ std::string file_string;
+ while((strbuffern = strtok_r(strfile_buf,"\n",&outer_ptr)) != NULL){
+ Debug("reggie-suffix","strbuffern is %s",strbuffern);
+ if(*strbuffern == '#'){
+ Debug("reggie-suffix","# is %s ",strbuffern);
+ strfile_buf = NULL;
+ continue;
+ }
+ if((strchr(strbuffern,',')) != NULL){
+ in = 0;
+ while((cp_line[in]=strtok(strbuffern," "))!=NULL) {
+ strbuffern = NULL;
+ in++;
+ }
+ if((strchr(cp_line[1],'=') != NULL) && (strstr(cp_line[1],"suffix"))){
+ if((cp_line[in] = strtok(cp_line[1],"=")) != NULL)
+ tmpvalue = strtok(NULL,"=");
+ while((cp_line[in] = strtok(tmpvalue,",")) != NULL){
+ in++;
+ tmpvalue = NULL;
+ }
+ }
+ for(int nk = 3; nk < in ;nk++){
+ //nbuf_len = strlen(cp_line[0]) + strlen(cp_line[2]) +strlen(cp_line[nk]) + 9;
+ //snprintf(buffer1,nbuf_len,"%s suffix=%s %s\n",cp_line[0],cp_line[nk],cp_line[2]);
+ sprintf(buffer1,"%s suffix=%s %s\n",cp_line[0],cp_line[nk],cp_line[2]);
+ file_string.append(buffer1);
+ }
+ }
+ else{
+ file_string.append(strbuffern);
+ file_string += "\n";
+ }
+ strfile_buf = NULL;
+ }
+ //file_string.erase(file_string.end()-1);
+ Debug("reggie_suffix","file_string is %s ",file_string.c_str());
+ ats_free(file_buf);
+ file_buf = (char*) ats_malloc(file_string.size()+1);
+ if(strcpy(file_buf,file_string.c_str()) == NULL){
+ ats_free(file_buf);
+ return 2;
+ }
+ ret = BuildTableFromString(file_buf);
+ ats_free(file_buf);
+ return ret;
+ }
+ /*end by reggie */
ret = BuildTableFromString(file_buf);
ats_free(file_buf);
was:
配置强制Cache jpeg js 等,需要多条配置
dest_domain=www.test.com suffix=jpeg ttl-in-cache=1m
dest_domain=www.test.com suffix=js ttl-in-cache=1m
现在改为用,分隔后缀
dest_domain=www.test.com suffix=jpeg,js,css,html ttl-in-cache=1m
> Cache control with muti suffix
> -------------------------------
>
> Key: TS-2008
> URL: https://issues.apache.org/jira/browse/TS-2008
> Project: Traffic Server
> Issue Type: New Feature
> Components: Cache
> Reporter: bettydramit
>
> 配置强制Cache jpeg js 等,需要多条配置
> dest_domain=www.test.com suffix=jpeg ttl-in-cache=1m
> dest_domain=www.test.com suffix=js ttl-in-cache=1m
> 现在改为用,分隔后缀
> dest_domain=www.test.com suffix=jpeg,js,css,html ttl-in-cache=1m
> patch:
> diff -Nur ts-3.3.1/proxy/ControlMatcher.cc ts-3.3.1-new/proxy/ControlMatcher.cc
> --- ts-3.3.1/proxy/ControlMatcher.cc 2013-03-10 03:44:28.000000000 +0800
> +++ ts-3.3.1-new/proxy/ControlMatcher.cc 2013-07-08 22:42:31.568980245 +0800
> @@ -44,7 +44,7 @@
> #include "P_Cache.h"
> #include "P_SplitDNS.h"
> #include "congest/Congestion.h"
> -
> +#include <string>
> /****************************************************************
> * Place all template instantiations at the bottom of the file
> ****************************************************************/
> @@ -815,6 +815,63 @@
> if (file_buf == NULL) {
> return 1;
> }
> + /* add by reggie */
> + if(strcmp("[CacheControl]",matcher_name) == 0){
> + Debug("reggie-suffix","file_string is begin" );
> + char *strbuffern = NULL;
> + char *strfile_buf = file_buf, *tmpvalue = NULL;
> + char *cp_line[64];
> + int in = 0;
> + char buffer1[128] = {0};
> + char *outer_ptr=NULL;
> + std::string file_string;
> + while((strbuffern = strtok_r(strfile_buf,"\n",&outer_ptr)) != NULL){
> + Debug("reggie-suffix","strbuffern is %s",strbuffern);
> + if(*strbuffern == '#'){
> + Debug("reggie-suffix","# is %s ",strbuffern);
> + strfile_buf = NULL;
> + continue;
> + }
> + if((strchr(strbuffern,',')) != NULL){
> + in = 0;
> + while((cp_line[in]=strtok(strbuffern," "))!=NULL) {
> + strbuffern = NULL;
> + in++;
> + }
> + if((strchr(cp_line[1],'=') != NULL) && (strstr(cp_line[1],"suffix"))){
> + if((cp_line[in] = strtok(cp_line[1],"=")) != NULL)
> + tmpvalue = strtok(NULL,"=");
> + while((cp_line[in] = strtok(tmpvalue,",")) != NULL){
> + in++;
> + tmpvalue = NULL;
> + }
> + }
> + for(int nk = 3; nk < in ;nk++){
> + //nbuf_len = strlen(cp_line[0]) + strlen(cp_line[2]) +strlen(cp_line[nk]) + 9;
> + //snprintf(buffer1,nbuf_len,"%s suffix=%s %s\n",cp_line[0],cp_line[nk],cp_line[2]);
> + sprintf(buffer1,"%s suffix=%s %s\n",cp_line[0],cp_line[nk],cp_line[2]);
> + file_string.append(buffer1);
> + }
> + }
> + else{
> + file_string.append(strbuffern);
> + file_string += "\n";
> + }
> + strfile_buf = NULL;
> + }
> + //file_string.erase(file_string.end()-1);
> + Debug("reggie_suffix","file_string is %s ",file_string.c_str());
> + ats_free(file_buf);
> + file_buf = (char*) ats_malloc(file_string.size()+1);
> + if(strcpy(file_buf,file_string.c_str()) == NULL){
> + ats_free(file_buf);
> + return 2;
> + }
> + ret = BuildTableFromString(file_buf);
> + ats_free(file_buf);
> + return ret;
> + }
> + /*end by reggie */
>
> ret = BuildTableFromString(file_buf);
> ats_free(file_buf);
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira