[wordpress插件] Appcachify追查

wordpress 插件 文章 2020-02-20 01:00 574 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

The plugin adds an iframe to the footer of your website which points to example.com/manifest.

该插件会在您网站的页脚中添加一个iframe,该iframe指向 example.com/manifest

That URL is an empty page that references the generated manifest file at example.com/manifest.appcache.

该URL是一个空页面,引用了 example.com/manifest.appcache 上生成的清单文件。

The manifest itself is built in the following way:

清单本身是通过以下方式构建的:

    1. adds URLs of all queued scripts and styles
    2. 添加所有排队的脚本和样式的URL

    3. searches theme files and folder for any images or other static assets
    4. 在主题文件和文件夹中搜索任何图像或其他静态资产

    5. if a theme has a 307.php template it is used as an offline fallback
    6. 如果主题具有307.php模板,则将其用作脱机后备广告

    7. a timestamp of the most recently modified file is added to force appcache to refresh
    8. 添加了最近修改文件的时间戳,以强制刷新应用缓存

    The net result of all this is that your main static files are stored locally on your visitors devices.

    所有这些的最终结果是,主要的静态文件存储在本地的访问者设备上。

    For mobile this greatly helps to improve download and rendering times.

    对于移动设备,这大大有助于缩短下载和渲染时间。

    Documentation

    文档

    Adding items to the manifest

    将商品添加到清单

    Appcache can do more than store static assets.

    Appcache可以做的不仅仅是存储静态资产。

    You could cache entire pages, or add fallbacks for when a user is offline.

    您可以缓存整个页面,也可以为用户离线时添加备用。

    There are 3 main sections to a manifest:

    清单有3个主要部分:

    CACHE

    CACHE

    The main CACHE section is for URLs that should be explicitly cached.

    CACHE 主要部分用于应显式缓存的URL。

      <?php

    add_filter( 'appcache_cache', function( $urls ) {   

    add_filter('appcache_cache',function($ urls){   

    $urls[] = '/page-available-offline/';   

    $ urls [] ='/ page-available-offline /';   

    return $urls;

    返回$ urls;

    } );

    });

    ?>

    ?>

    NETWORK

    网络

    This section is for specifying URLs that should never be cached.

    此部分用于指定不应永远进行缓存的URL。

      <?php

    add_filter( 'appcache_network', function( $urls ) {   

    add_filter('appcache_network',function($ urls){   

    $urls[] = '*';   

    $ urls [] ='*';   

    $urls[] = '/online-only-page/';   

    $ urls [] ='/ online-only-page /';   

    return $urls;

    返回$ urls;

    } );

    });

    ?>

    ?>

    FALLBACK

    Fallback

    The fallback section allows you to set fallback pages or images if the user is offline.

    如果用户处于离线状态,可以使用后备部分来设置后备页面或图像。

      <?php

    add_filter( 'appcache_fallback', function( $patterns ) {   

    add_filter('appcache_fallback',function($ patterns){   

    $patterns[] = 'wp-content/uploads/ wp-content/uploads/offline.jpg';   

    $ patterns [] ='wp-content / uploads / wp-content / uploads / offline.jpg';   

    return $patterns;

    返回$ patterns;

    } );

    });

    ?>

    ?>

    The update header

    更新标头

    Appcaches are refetched when the manifest file content changes so we add a few items as comments at the top of the file.

    清单文件内容更改时,将重新获取应用程序缓存,因此我们在文件顶部添加了一些项目作为注释。

      1. The current theme (and version if available)
      2. 当前主题(和版本,如果可用)

      3. The most recent modified time of any files we find the server path for
      4. 我们找到服务器文件路径的所有文件的最新修改时间

      5. The size of all the files that we find a server path for

        我们找到服务器路径的所有文件的大小

        get_var( “SELECT post_modified FROM $wpdb->posts WHERE post_type = ‘post’ ORDER BY post_modified DESC LIMIT 1” );
           

        get_var(“从$ wpdb->中选择post_modified = posts WHERE post_type ='post'ORDER BY post_modified DESC LIMIT 1”);
           

        return $headers;

        返回$ headers;

        } );

        });

        ?>

      6. ?>

      More about appcache

      有关appcache的更多信息

      I strongly recommend learning more about what you can do with appcache by reading the following articles:

      我强烈建议您阅读以下文章,详细了解如何使用appcache:

安装步骤

Upload the plugin to your plugins directory and activate it.

将插件上传到您的插件目录并激活它。

There’s no configuration involved or settings screen.

没有任何配置或设置屏幕。

下载地址
https://downloads.wordpress.org/plugin/appcachify.zip
-EOF-

AI助手支持GPT4.0