zoukankan      html  css  js  c++  java
  • 初学 Nginx (一) SSI 的作用

    SSI:Server Side Include,是一种基于服务端的网页制作技术,

    Nginx ssi 的例子如下:

    It took a little while to figure this out and it’s handy for creating one-off sites with “dynamic” content without a web framework.

    user nginx;
    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        sendfile      on;
        tcp_nopush    on;
        keepalive_timeout 10;
        gzip          on;
    
        server {
            server_name  localhost;
            charset      utf-8;
            access_log   /var/log/nginx/access.log;
    
            root    /var/www;
    
            location = / {
                rewrite ^ /home redirect;
            }
    
            location / {
                ssi on;
                set $inc $request_uri;
                if (!-f $request_filename) {
                    rewrite ^ /index.html last;
                }
                if (!-f $document_root$inc.html) {
                    return 404;
                }
            }
        }
    }
    

    Then if you have an index.html file similar to this:

    <html>
      <body>
        <!--# include file="$inc.html" -->
      </body>
    </html>
    

    it will now include (via SSI) whatever page is requested. So for example /home would include home.html into index.html. This makes it easy to have a common style (headers and footers) without resorting to PHP or a framework.

    It assumes home.html exists.

    从列子不难看出 ssi的 的作用, 有点像jsp的include 标签 ,不同的是  ssi 引用的 页面 来自静态页面 ,是不经过后台的。

    这里是一点点 体会。有不同看法的欢迎大家经常讨论。

  • 相关阅读:
    机器学习-数据与特征工程
    机器学习-聚类(clustering)算法:K-means算法
    机器学习-回归中的相关度和R平方值
    机器学习-非线性回归(Logistic Regression)及应用
    机器学习-多元线性回归(一)
    机器学习-简单线性回归(二)
    MVC,MVP,MVVM
    Git从入门到熟练
    NSNotificationCenter
    FMDB的线程安全
  • 原文地址:https://www.cnblogs.com/daipenglin/p/5968031.html
Copyright © 2011-2022 走看看