【问题标题】:Reduce CloudSQL instance hours (wordpress)减少 CloudSQL 实例小时数 (wordpress)
【发布时间】:2014-12-31 09:32:00
【问题描述】:

我在 GAE 上安装了 wordpress。这是一个更新很少的网站,每天的访问者很少(最多 100 人)。我想缓存这个网站以最小化 cloudSQL 成本。

我应该采取哪些步骤来最大程度地减少 CloudSQL 实例的启动?

我已经安装了 MEMCACHED 插件和我的 BATCACHED 插件。

我的 wp-config 有以下内容:

$batcache = [
      'seconds'=>0,
      'max_age'=>300*60, // 300 minutes
      'debug'=>false
    ];

我的 app.yaml:

application: MY ID
version: 104
runtime: php
api_version: 1
default_expiration: "1d"

handlers:
- url: /(.*\.(htm$|html$|css$|js$))
  static_files: wordpress/\1
  upload: wordpress/.*\.(htm$|html$|css$|js$)
  application_readable: true




- url: /wp-content/(.*\.(ico$|jpg$|png$|gif$))
  static_files: wordpress/wp-content/\1
  upload: wordpress/wp-content/.*\.(ico$|jpg$|png$|gif$)
  application_readable: true




- url: /(.*\.(ico$|jpg$|png$|gif$))
  static_files: wordpress/\1
  upload: wordpress/.*\.(ico$|jpg$|png$|gif$)  
  application_readable: true








- url: /wp-admin/(.+)
  script: wordpress/wp-admin/\1
  secure: always

- url: /wp-admin/
  script: wordpress/wp-admin/index.php
  secure: always

- url: /wp-login.php
  script: wordpress/wp-login.php
  secure: always

- url: /wp-cron.php
  script: wordpress/wp-cron.php
  login: admin

- url: /xmlrpc.php
  script: wordpress/xmlrpc.php




- url: /(.*\.(appcache|manifest))
  mime_type: text/cache-manifest
  static_files: wordpress/\1
  upload: wordpress/(.*\.(appcache|manifest))
  expiration: "0m"
  application_readable: true


- url: /(.*\.atom)
  mime_type: application/atom+xml
  static_files: wordpress/\1
  upload: wordpress/(.*\.atom)
  expiration: "1h"
  application_readable: true



- url: /(.*\.crx)
  mime_type: application/x-chrome-extension
  static_files: wordpress/\1
  upload: wordpress/(.*\.crx)
  application_readable: true



- url: /(.*\.css)
  mime_type: text/css
  static_files: wordpress/\1
  upload: wordpress/(.*\.css)
  application_readable: true



- url: /(.*\.eot)
  mime_type: application/vnd.ms-fontobject
  static_files: wordpress/\1
  upload: wordpress/(.*\.eot)
  application_readable: true



- url: /(.*\.htc)
  mime_type: text/x-component
  static_files: wordpress/\1
  upload: wordpress/(.*\.htc)
  application_readable: true



- url: /(.*\.html)
  mime_type: text/html
  static_files: wordpress/\1
  upload: wordpress/(.*\.html)
  expiration: "1h"
  application_readable: true



- url: /(.*\.ico)
  mime_type: image/x-icon
  static_files: wordpress/\1
  upload: wordpress/(.*\.ico)
  expiration: "7d"
  application_readable: true



- url: /(.*\.js)
  mime_type: text/javascript
  static_files: wordpress/\1
  upload: wordpress/(.*\.js)
  application_readable: true



- url: /(.*\.json)
  mime_type: application/json
  static_files: wordpress/\1
  upload: wordpress/(.*\.json)
  expiration: "1h"
  application_readable: true



- url: /(.*\.m4v)
  mime_type: video/m4v
  static_files: wordpress/\1
  upload: wordpress/(.*\.m4v)
  application_readable: true



- url: /(.*\.mp4)
  mime_type: video/mp4
  static_files: wordpress/\1
  upload: wordpress/(.*\.mp4)
  application_readable: true



- url: /(.*\.(ogg|oga))
  mime_type: audio/ogg
  static_files: wordpress/\1
  upload: wordpress/(.*\.(ogg|oga))
  application_readable: true



- url: /(.*\.ogv)
  mime_type: video/ogg
  static_files: wordpress/\1
  upload: wordpress/(.*\.ogv)
  application_readable: true



- url: /(.*\.otf)
  mime_type: font/opentype
  static_files: wordpress/\1
  upload: wordpress/(.*\.otf)
  application_readable: true



- url: /(.*\.rss)
  mime_type: application/rss+xml
  static_files: wordpress/\1
  upload: wordpress/(.*\.rss)
  expiration: "1h"
  application_readable: true



- url: /(.*\.safariextz)
  mime_type: application/octet-stream
  static_files: wordpress/\1
  upload: wordpress/(.*\.safariextz)
  application_readable: true



- url: /(.*\.(svg|svgz))
  mime_type: images/svg+xml
  static_files: wordpress/\1
  upload: wordpress/(.*\.(svg|svgz))
  application_readable: true



- url: /(.*\.swf)
  mime_type: application/x-shockwave-flash
  static_files: wordpress/\1
  upload: wordpress/(.*\.swf)
  application_readable: true



- url: /(.*\.ttf)
  mime_type: font/truetype
  static_files: wordpress/\1
  upload: wordpress/(.*\.ttf)
  application_readable: true



- url: /(.*\.txt)
  mime_type: text/plain
  static_files: wordpress/\1
  upload: wordpress/(.*\.txt)
  application_readable: true



- url: /(.*\.unity3d)
  mime_type: application/vnd.unity
  static_files: wordpress/\1
  upload: wordpress/(.*\.unity3d)
  application_readable: true



- url: /(.*\.webm)
  mime_type: video/webm
  static_files: wordpress/\1
  upload: wordpress/(.*\.webm)
  application_readable: true



- url: /(.*\.webp)
  mime_type: image/webp
  static_files: wordpress/\1
  upload: wordpress/(.*\.webp)
  application_readable: true



- url: /(.*\.woff)
  mime_type: application/x-font-woff
  static_files: wordpress/\1
  upload: wordpress/(.*\.woff)
  application_readable: true



- url: /(.*\.xml)
  mime_type: application/xml
  static_files: wordpress/\1
  upload: wordpress/(.*\.xml)
  expiration: "1h"
  application_readable: true



- url: /(.*\.xpi)
  mime_type: application/x-xpinstall
  static_files: wordpress/\1
  upload: wordpress/(.*\.xpi)
  application_readable: true



# audio files
- url: /(.*\.(mid|midi|mp3|wav))
  static_files: wordpress/\1
  upload: wordpress/(.*\.(mid|midi|mp3|wav))  
  application_readable: true



# windows files
- url: /(.*\.(doc|exe|ppt|rtf|xls))
  static_files: wordpress/\1
  upload: wordpress/(.*\.(doc|exe|ppt|rtf|xls))
  application_readable: true



# compressed files
- url: /(.*\.(bz2|gz|rar|tar|tgz|zip))
  static_files: wordpress/\1
  upload: wordpress/(.*\.(bz2|gz|rar|tar|tgz|zip))  
  application_readable: true



- url: /wp-(.+).php
  script: wordpress/wp-\1.php

- url: /(.+)?/?
  script: wordpress/index.php

我想知道在启动我的 CloudSQL 实例时减少 wordpress 的所有方法。另外,我想知道如何检查缓存是否正常工作。

目前,即使我在没有登录 wordpress 的情况下访问一个页面,它也会显示一个 CloudSQL 实例已启动(一个活动连接),我认为如果缓存工作正常,情况就不应该出现这种情况

【问题讨论】:

    标签: php wordpress google-app-engine caching google-cloud-sql


    【解决方案1】:

    我相当肯定,即使使用 batcache,WordPress 核心仍然会尝试连接到 SQL 数据库以确保连接有效。

    您需要研究其中一个静态整页缓存插件以尝试实现您所追求的目标 - 它们似乎有选项可以在不加载 WordPress 核心的情况下返回页面。

    【讨论】:

    • 如何创建和提供这些静态页面?应用引擎不允许文件处理。有没有这样的插件可以工作?
    • 我会从一个与 S3 一起作为 CDN 工作的插件开始,看看它能走多远。
    • @harvey_slash :您找到解决方案了吗,即有效的缓存插件?我有同样的问题,很少更新 batcached 站点,仍然继续使用大约 30 天的价值 SQL 小时/月,这非常糟糕。
    【解决方案2】:

    如果您已设置 Scheduled Tasks 以频繁访问 wp-cron.php,您可能需要考虑降低此运行的频率。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      • 2019-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-09
      相关资源
      最近更新 更多