Title: Separated cache based on value from PHP
Last modified: February 12, 2017

---

# Separated cache based on value from PHP

 *  Resolved [batooo](https://wordpress.org/support/users/batooo/)
 * (@batooo)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/separated-cache-based-on-value-from-php/)
 * Hello,
 * I have custom 404 pages but they are almost same size as standard page. Bots 
   crawl some archive that don`t exist and my server is using much more bandwidth.
   I want to detect if request is robot and pass some header via PHP. Then Litespeed
   cache should give my empty page to robots and real one to real visitors.
 * How i can make this?
    So far, i made my function is PHP to detect if is robot
   on 404 requests. What is next?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [batooo](https://wordpress.org/support/users/batooo/)
 * (@batooo)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/separated-cache-based-on-value-from-php/#post-8795039)
 * I`m using PHP version of [ua-parser](https://github.com/tobie/ua-parser) but 
   they also have c++ version. Its very simple and accurate. Also updates are very
   often on regex logic.
 * Why not including into Litespeed, so users can easily use this variables in many
   situations:
       1. Separated cache for robots or maybe based on browser family, eq: Chrome
    -  1. Also using into plugin, like ‘Use Litespeed Mobile Detector’ for separated
          views
    -  1. Also blocking not-important crawlers eq: If is Spider and family != GoogleBot,
          return 404
 * Something similar as your GEO feature.
 * Hm?
    -  This reply was modified 9 years, 3 months ago by [batooo](https://wordpress.org/support/users/batooo/).
    -  This reply was modified 9 years, 3 months ago by [batooo](https://wordpress.org/support/users/batooo/).
 *  Plugin Author [LiteSpeed Technologies](https://wordpress.org/support/users/litespeedtech/)
 * (@litespeedtech)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/separated-cache-based-on-value-from-php/#post-8799141)
 * Hi [@batooo](https://wordpress.org/support/users/batooo/),
 * Are the 404 pages generated by PHP? If not, you can just add rewrite rules to
   your rules section/.htaccess to rewrite the url to your 404 page.
 * If they _are_ generated by PHP, you can create your own rewrite rule similar 
   to our mobile vary.
 *     ```
       RewriteCond %{HTTP_USER_AGENT} USERAGENT_REGEX [NC]
       RewriteRule .* - [E=Cache-Control:vary=isrobot]
       ```
   
 * This rewrite rule will tell the server to cache all pages with a user agent that
   matches USERAGENT_REGEX with the isrobot vary. You can put this rule somewhere
   within the <ifmodule LiteSpeed> block.
 * Let me know if any of these steps are confusing.
 * Cheers,
    Kevin

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Separated cache based on value from PHP’ is closed to new replies.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [LiteSpeed Technologies](https://wordpress.org/support/users/litespeedtech/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/separated-cache-based-on-value-from-php/#post-8799141)
 * Status: resolved