zoukankan      html  css  js  c++  java
  • 时间戳有什么作用,如何定义时间戳??

    当我们在做项目的时候,引用js或者css是通常会在后面加上时间戳,举例如下:

     <link href="/congent/css1?v=@Config.InitTimestamp" type="text/css" rel="stylesheet"/>

    v的后面就是引用的时间戳,那么时间有什么作用,该如何定义了?具体如下>>

    时间戳的作用

    好多Linux + Apache的服务器都会对CSS、JS和图片这些静态的内容设置缓存,到了IE这里又会在本地做一个缓存。所以当我们更新了CSS文件之后,常常会出现客户端没有更新,导致显示出现问题,所以使用了时间戳。总之一句话概括使用时间戳的目的就是:禁止缓存css、js,使浏览器同步更新到服务器端最新的静态内容。

    定义时间戳

            /// <summary>
            /// 站点初次加载时间戳
            /// </summary>
            private static string _initTimestamp;
            public static string InitTimestamp
            {
                get
                {
                    if (string.IsNullOrEmpty(_initTimestamp))
                    {
                        var start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local);
                        _initTimestamp = Convert.ToInt64((DateTime.Now - start).TotalSeconds).ToString();
                    }
                    return _initTimestamp;
                }
            }
  • 相关阅读:
    系统调用简单总结
    系统调用原理详解
    总结:c 语言与Linux操作系统的关系
    poj3171 Cleaning Shifts
    洛谷P1032 字串变换
    poj3662 Telephone Lines
    洛谷P1073 最优贸易
    Uva1330/poj1964 City Game
    poj2559/SP1805 Largest Rectangle in a Histogram
    洛谷 P1196 [NOI2002]银河英雄传说
  • 原文地址:https://www.cnblogs.com/goodstudyqiiqi/p/10154286.html
Copyright © 2011-2022 走看看