阴符经与自动化睡中收入第一原则及Dynamic Serving优化手机页面
有一段时间没有发帖了。这段时间在找Prebid Header Bidding的合作公司,一些大公司根本不理会我这种中小网站,写信过去连个水泡都没有,由此也可以想象到互联网广告的巨大吸金力。
继而又想到自动化睡中收入的主题。
睡中收入
所谓睡中收入,也就是睡觉中、旅游中、游戏中、看碟中仍然能够自动产生的收入。
如何取得各人有各法,有写书版权、房租收入、网站广告、Youtuber等等诸法,于我这种知天命而无甚财运的人,能获得中产阶级偏上的自动化收入,有能力齐家,有时间修身就很不错,也算是此生处于这个信息时代的一个福报。
今天突然想到阴符经的几句话
天之无恩而大恩生,迅雷烈风,莫不蠢然,至乐性馀,至静性廉。天之至私,用之至公,禽之制在气。
保持至乐至静,常觉有余,而无贪爱。
天之至私,用之至公。此之谓似分实合的世界,即天人合一与All is One。
禽之制在气, 擒之通假,掌握。其要点在于气,气乃是交流。天人合一之要点就是气,身中之气与万物之气并无二致。其规律就是流转不息。
故此自动化睡中收入的第一原则就是:
你付出价值(气)给世界,世界会回馈价值(气)给你
Dynamic Serving优化手机页面
为什么要做这个呢,因为我要提供价值给网站客户,令他们访问更快。
Google也是身体力行这个原则的公司,故此他们有手机优先的搜索引擎排名规则。
前几年对手机用户的策略是采用Responsive design。就是一个网页电脑版和手机版都做了,自动显示合适的页面。
而 Dynamic Serving则是在服务器端就判断用户的设备,再将合适的页面呈现给用户。其优点就是页面更小,尤其对手机用户,可以省掉大量针对电脑用户的代码,可以大幅提高速度及用户体验。
Google的说明提到要使用Vary http header技术
nginx缺省是没有这个选项,需要安装ngx_headers_more
考虑到下次可能还需要在其他项目中设置,具体一点记录一下:
先搞清已经安装的nginx版本
sudo nginx -V
然后下载同一版本的nginx
wget 'http://nginx.org/download/nginx-1.14.0.tar.gz'
tar -xzvf nginx-1.14.0.tar.gz
cd nginx-1.14.0/
./configure --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-FIJPpj/nginx-1.14.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --add-dynamic-module=/path/headers-more-nginx-module-0.33
一路上可能会要求装不少插件,因为nginx以前不是编译安装的。
install libgd-dev in case of this error:
./configure: error: the HTTP image filter module requires the GD library.
install libgeoip-dev in case of:
./configure: error: the GeoIP module requires the GeoIP library.
install libssl-dev in case of:
./configure: error: SSL modules require the OpenSSL library.
install libpcre++-dev in case of:
./configure: error: the HTTP rewrite module requires the PCRE library.
install libxslt1-dev in case of:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
运行成功后出来结果,看到modules的path是:
nginx modules path: "/usr/lib/nginx/modules"
make module
然后将ngx_http_headers_more_filter_module.so拷贝到上面的path里
编辑nginx.conf
...
load_module modules/ngx_http_headers_more_filter_module.so;
...
http{
...
#gzip_vary on;
more_set_headers -s 200 'Vary: Accept-Encoding, User-Agent';
,,,}
编辑sites-avaible里的网站配置文件
map $geoip_country_code $preferred_upstream {
default eu;
US us;
}
map $geoip_country_code $preferred_upstream_mp {
default eum;
US usm;
}
upstream us {
server unix:/path/us.sock;
}
upstream eu {
server unix:/path/eu.sock;
}
upstream usm {
server unix:/path/usm.sock;
}
upstream eum {
server unix:/path/eum.sock;
}
server {
....
location @fallback {
# add trailing slash if url has no dot in it
rewrite ^/([^\.]*[^/])$ /$1/ permanent;
include uwsgi_params;
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* '(iPhone|iPod|iPad|Android|BlackBerry|webOS|Windows Phone)') {
set $mobile_rewrite perform;
}
if ($mobile_rewrite = do_not_perform) {
uwsgi_pass $preferred_upstream;
break;
}
if ($mobile_rewrite = perform) {
uwsgi_pass $preferred_upstream_mp;
break;
}
.......
}
...
}
这样网站就将手机用户分流到不同的socket。
刚开始这样操作还老有问题,手机访问出电脑版,电脑访问出手机版。又研究了半天,发现是django的cache有问题,将memcached停用就解决问题了。
用pagespeed测试一下,原来只有30分左右的手机网页速度一下跳到了90分。
写这个帖子的时候处理邮件又发现有一个命令,随机生成包含各种字符,记录到这里
tr -cd '[:alpha:]' < /dev/urandom | fold -w20 | head -200000 > file.txt
20个字符一行,共200000行,输出到file.txt
相关文章:
- 2019/06/10 阴符经之五贼各家解
- 2019/03/06 黄帝阴符经金陵道人唐淳注
- 2019/03/03 阴符经褚遂良帖及刘一明注

Jesse Lau
网名遁去的一,简称遁一。2012年定居新西兰至今,自由职业者。
本文采用知识共享署名 4.0 国际许可协议进行许可。简而言之,可随意转发转载,转载请注明出处。