close
附註:本文僅屬記錄與經驗分享且在非乾淨電腦中安裝,若有遺漏或錯誤煩請指正,如有侵權請來信告知。
[expand title="發表日期:2014/09/08 最後更新:2014/09/08" alt="點選觀看詳細更新記錄"]

  • 2014/09/08, 新增文章


[/expand]


0.目錄



  1. 問題描述

  2. 解決方案

  3. 參考資料

  4. 後記







  • 需要準備的檔案:無

  • 問題發生環境:WordPress (4.0.0) + WPtouch Mobile Plugin (3.4.9) + WP Super Cache (1.4.2)







1.問題描述


使用wp外掛 WP Super Cache 會讓 WPtouch Mobile Plugin 無法正成運作。


這是一個很普遍的問題,連WPtouch官網上都有針對WP Super Cache的部份做說明,不過都是英文看的有點辛苦XD




以下會針對這個問題記錄我的解決方法


 

2.解決方案


快速筆記為:

  1. 開啟後台進入WP Super Cache管理頁面

  2. 開啟WP Super Cache快取功能 (若已開啟,跳到step 3)

  3. 在進階選項中啟用"行動裝置支援" (Mobile device support)

  4. 新增"被拒絕的使用者代理" 清單 (Rejected User Agents)  --->清單請見此

  5. 內容清除以產生或過期的快取

  6. 使用手機觀看結果


以下則一步一步說明:

首先開啟後台,進入WP Super Cache管理頁面


如果還沒啟動快取功能請先啟動快取 (如果還沒啟動就有問題,那應該是WPtouch的問題,不是WPSC衝突的問題喔~)



[caption id="attachment_644" align="aligncenter" width="792"][WP]在進階選項啟動快取 [WP]在進階選項啟動快取[/caption]

在進階選項中啟動"行動裝置支援" (Mobile device support) (看來是翻譯不完全這邊還是英文的)



[caption id="attachment_645" align="aligncenter" width="792"][WP]在進階選項啟用行動裝置支援(Mobile device support) [WP]在進階選項啟用行動裝置支援(Mobile device support)[/caption]

接著一樣在進階選項往下找,有一個"被拒絕的使用者代理" 清單 (Rejected User Agents)


根據官方的說明,可以把以下(預設)清單加入 (如有特殊需求可再自行增加)



iPhone
iPod
Android
BB10
BlackBerry
webOS
IEMobile/7.0
IEMobile/9.0
IEMobile/10.0
MSIE 10.0
iPad
PlayBook
Xoom
P160U
SCH-I800
Nexus 7
Touch

(官方說明文件:http://www.wptouch.com/support/knowledgebase/default-mobile-device-user-agents/#cacheuas)

[caption id="attachment_646" align="aligncenter" width="773"][WP]在進階選項 增加被拒絕的使用者代理(Rejected User Agents) [WP]在進階選項 增加被拒絕的使用者代理(Rejected User Agents)[/caption]

其實到這邊用手機就能看到手機版畫面了


不過官方文件提到,還要到內容清除以產生或過期的快取,然後就會自動產生新的快取


(因為如果有之前產生過的快取,依然會發送快取,所以更新UA-List後要做清除快取的動作)



[caption id="attachment_647" align="aligncenter" width="489"][WP]進入內容(Contents)點選刪除過期檔案 及 刪除快取 [WP]進入內容(Contents)點選刪除過期檔案 及 刪除快取[/caption]

使用手機開啟網頁就能看到畫面



[caption id="attachment_648" align="aligncenter" width="510"][WP]用手機開啟網站就能成功看到WPtouch提供的手機版內容 [WP]用手機開啟網站就能成功看到WPtouch提供的手機版內容[/caption]

看到畫面就完成了


以下此附上官方的內容:(轉載自http://www.wptouch.com/support/knowledgebase/optimizing-caching-plugins-for-mobile-use/#wpsupercache)


[expand title="點此展開官方的內容" alt="點此展開官方的內容"]

  1. Enable Mobile device support.
    In the Advanced tab of the WP Super Cache settings select “Mobile Device Support”* and click “Update Status”.

  2. Exclude mobile user agents.
    Still in the Advanced tab, scroll down to the “Rejected User Agents” area. Paste the entire list of mobile user agents found in our list of “User agent list for configuring cache plugins” into the field and click “Save UA Strings”.
    Please note: If you have added support for additional mobile devices in WPtouch Pro’s Compatibility > Custom User Agents field, you must also include those user agents in the “Rejected User Agents” area in WP Super Cache.

  3. Delete WP Super Cache’s stored files (its cache).

  4. In the “Contents” tab, click “Delete Cache”  and “Delete Expired” to delete pages that were likely cached before adding the new list of rejected user agents.


WP Super cache should now be configured correctly to ignore mobile user agents while still caching pages viewed on a desktop browser.

[/expand]

 

3.參考資料



 

4.後記


最近外掛大更新,發現首頁不會自動出現手機版(WPtouch)但其他頁面卻沒問題,以為是更新後出現的bug


後來在後台查找設定時看到WPtouch有一個通知,他說WP Super Cache沒有正確設定,才讓我回憶起這個問題


進入WP Super Cache設定頁面發現之前加入的User Agent list不見了(變成初始值)


可能是某次更新他清掉的,最近才發現這個問題,重新加入就完成了


而為什麼只有首頁無法顯示但其他內頁可以呢?


稍微看了一下設定發現他有一個清單為:"不要被快取的頁面",預設包含


wp-.*\.php
index\.php


也就是說首頁預設是不會被快取的,而其他頁面依然有之前建立的快取


因此開首頁時,還是傳送新的頁面,但因為WP Super Cache的關係所以無法顯示WPtouch的內容


而開其他頁面時,雖然WP Super Cache沒有正確設定,但之前有建立過快取所以還是會顯示舊的內容


其實這個問題之前剛安裝這兩個外掛時就有遇過一次,當時就是這樣解決的(也是看了好久的英文XD)


只是當時沒有記錄,事隔太久都忘記了,這次特別記錄一下

arrow
arrow
    全站熱搜

    Robarter 發表在 痞客邦 留言(0) 人氣()