• Resolved batooo

    (@batooo)


    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

    (@batooo)

    I`m using PHP version of 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:

        Separated cache for robots or maybe based on browser family, eq: Chrome
        Also using into plugin, like ‘Use Litespeed Mobile Detector’ for separated views
        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 8 years ago by batooo.
    • This reply was modified 8 years ago by batooo.
    Plugin Author LiteSpeed Technologies

    (@litespeedtech)

    Hi @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.