• Hello,
    I would like to start preloading pages using php.

    The thing is:
    I have some script running every 2 hours doing something with posts and when it´s done I want that script to call something like “wp super cache start preloading” and it would delete cache and preload it once again. The best would be if I could delete cache and preload it for just some categories or posts.

    Is there any way how to do it, please?

    Kind Regards, Josef

Viewing 1 replies (of 1 total)
  • First cache preload does not preload custom post types (if you use it!)
    Than better to use external cache preloader as script below setting it on your linux server as CRON job:

    #!/bin/bash
    #
    # This script reload all the cache on web
    #
    CACHEDDOMAIN0001="example.com"
    WARMLY_REJECT="gif,jpg,jpeg,png,pdf,txt,xml,ico,svg,css,js,json,eot,woff,woff2,ttf"
    
    cd ~/web/${CACHEDDOMAIN0001}/public_html/
    /usr/local/bin/wp super-cache flush;
    cd ~
    
    #rm -R /home/admin/web/${CACHEDDOMAIN0001}/public_html/wp-content/cache/supercache/${CACHEDDOMAIN0001}/
    
    # ---  what's about --no-cache  parameter???
    
    # Fetching desktop version
    wget --content-disposition --reject-regex "wp-json|wp-includes" --reject=${WARMLY_REJECT} --spider -o wget-${CACHEDDOMAIN0001}.log -e robots=off -r -l 5 -p -S --header="X-Bypass-Cache: 1" ${CACHEDDOMAIN0001}
    # Fetching mobile version
    wget --content-disposition --reject-regex "wp-json|wp-includes" --reject=${WARMLY_REJECT} --spider -o wget-${CACHEDDOMAIN0001}.log -e robots=off -r -l 5 -p -S --header="X-Bypass-Cache: 1" ${CACHEDDOMAIN0001} --user-agent='Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A366 Safari/600.1.4'
    # Deleting temp wget directory
    rm -R ./${CACHEDDOMAIN0001}
    
Viewing 1 replies (of 1 total)

The topic ‘start preloading via PHP’ is closed to new replies.