多个文件服务器读写,这里可采用SMB协议
页面静态化,可采用freemarker开源框架
如果考虑到大量的读写请求,则将请求分布式或采用调度的办法来解决
第一点我们首先应该考虑文件服务器与静态页面的映射关系,即什么文件应该读写到哪台服务器,这个关系最简单的办法是随机映射,然后将映射关系保存到数据库中即可,SMB常用的操作代码如下:
复制代码 代码如下:
    public static boolean exists(String filepath,String username,String pwd) throws Exception
    {
    SmbFile file = new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
try{
    return file.exists();
}catch(Exception ex){
    return false;
}
    }

public static boolean fileRename(String filepath,String newFilename,String username,String pwd)
    {
    try{
         SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
         if(f.isFile()){
     String str=filepath.substring(0,filepath.lastIndexOf("/"));
     str="smb://"+username+":"+pwd+"@"+str+"/"+newFilename;
     f.renameTo(new SmbFile(str));
         }else if(f.isDirectory()){
         String str=filepath.substring(0,filepath.length()-1);
         str=filepath.substring(0,str.lastIndexOf("/"));
         str="smb://"+username+":"+pwd+"@"+str+"/"+newFilename;
         f.renameTo(new SmbFile(str));              
         }
     return true;
    }catch(Exception ex){
        return false;
    }
    }

public static void mkdir(String dir,String username,String pwd)
{
try{
     SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+dir);
     if(!f.exists())
f.mkdir();
}catch(Exception ex)
{
}
}

public static void mkfile(String filepath,String username,String pwd)
{
try
{
     SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
     if(!f.exists())
f.createNewFile();
}catch(Exception ex)
{
}
}

public static void mkfile(String filepath,String username,String pwd,String content)
{
try
{
     SmbFile f=new SmbFile("smb://"+username+":"+pwd+"@"+filepath);
     if(!f.exists())
f.createNewFile();
writeFile(filepath,content,username,pwd);
}catch(Exception ex)
{
}
}

public static boolean isdir(String filepath,String username,String pwd) throws Exception
{
String dir="smb://"+username+":"+pwd+"@"+filepath;
SmbFile f=new SmbFile(dir);
return f.isDirectory();
}

第二点,页面静态化可由freemarker生成,freemarker的使用比较简单,我这里不再啰嗦,重复说了
第三点,调度中心,或把静态化的请求先保存到Task中,然后通过调度中心异步执行,可用我在博客中说道的另外一篇文章解决即可
标签:
大型网站,页面,静态化

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com

评论“通用大型网站页面静态化解决方案”

暂无“通用大型网站页面静态化解决方案”评论...

稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!

昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。

这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。

而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?