...
Code Block | ||||
---|---|---|---|---|
| ||||
#!/bin/sh # # Example of automating the process of purging the HTTP proxy cache for # a UT Web content site. # # This assumes: # * the script is running on the UT Web panel server # * The script is being run as the UT Web site account # * the URL to purge is the site's main URL (utwNNNNN.utweb.utexas.edu) # * all sub-URL's of the main site should be purged as well ($site/*) # # Season to taste. # siteuser=`whoami` site=http://$siteuser.utweb.utexas.edu urlstopurge="$site" utweb_prod_balancers=" utweb-px-z1-p01.its.utexas.edu utweb-px-z1-p02.its.utexas.edu " for b in $utweb_prod_balancers; do id=`echo $b | sed s/.its.utexas.edu/_http/` for u in $urlstopurge ; do echo === $b $site curl -v \ --cookie "balancer_id=$id" \ -X PURGE \ -D - "$u/*" done done |
- Log in to your site via your UT Web site account (not your developer account) via a SSH connection.
From a SSH client (Windows) or Terminal (OS X) window, you will need to connect to your site account's home directory on the panel server via a SSH connection::
Code Block ssh <utw10NNNNN>@panel.utweb.utexas.edu
Copy the clearcache.sh file in to your site account's home directory: To do this, type the following in to your command line:
Code Block language bash theme Midnight cp /utweb/common/src/examples/clearcache.sh clearcache.sh
Now that the file is in your home directory, we need to change the permissions of it to be executable. To do this, type the following in to your command line:
Code Block language bash theme Midnight chmod 750 clearcache.sh
Now that the file is executable, run the script by typing the following in to your command line:
Code Block language bash theme Midnight ./clearcache.sh
Real Output:
No Format language bash theme Midnight === utweb-px-z1-p01.its.utexas.edu http://utw10373.utweb.utexas.edu * About to connect() to utw10373.utweb.utexas.edu port 80 (#0) * Trying 128.83.21.174... connected * Connected to utw10373.utweb.utexas.edu (128.83.21.174) port 80 (#0) > PURGE /* HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.18 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4. > Host: utw10373.utweb.utexas.edu > Accept: */* > Cookie: balancer_id=utweb-px-z1-p01_http > < HTTP/1.1 204 No Content HTTP/1.1 204 No Content < Server: nginx Server: nginx < Date: Wed, 27 Apr 2016 17:55:41 GMT Date: Wed, 27 Apr 2016 17:55:41 GMT < X-CacheServer: 172.17.99.42 X-CacheServer: 172.17.99.42 < Set-Cookie: balancer_id=utweb-px-z1-p01_http|VyD9I|VyD9I; path=/ Set-Cookie: balancer_id=utweb-px-z1-p01_http|VyD9I|VyD9I; path=/ < * Connection #0 to host utw10373.utweb.utexas.edu left intact * Closing connection #0 === utweb-px-z1-p02.its.utexas.edu http://utw10373.utweb.utexas.edu * About to connect() to utw10373.utweb.utexas.edu port 80 (#0) * Trying 128.83.21.174... connected * Connected to utw10373.utweb.utexas.edu (128.83.21.174) port 80 (#0) > PURGE /* HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.18 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: utw10373.utweb.utexas.edu > Accept: */* > Cookie: balancer_id=utweb-px-z1-p02_http > < HTTP/1.1 204 No Content HTTP/1.1 204 No Content < Server: nginx Server: nginx < Date: Wed, 27 Apr 2016 17:55:41 GMT Date: Wed, 27 Apr 2016 17:55:41 GMT < X-CacheServer: 172.17.99.43 X-CacheServer: 172.17.99.43 < Set-Cookie: balancer_id=utweb-px-z1-p02_http|VyD9I|VyD9I; path=/ Set-Cookie: balancer_id=utweb-px-z1-p02_http|VyD9I|VyD9I; path=/ < * Connection #0 to host utw10373.utweb.utexas.edu left intact * Closing connection #0
Check to see if the proxy caches were flushed by typing this in to your command line:
Code Block language bash curl -vI utwNNNNN.utweb.utexas.edu
Real Output:
No Format language bash theme Midnight * About to connect() to utw10373.utweb.utexas.edu port 80 (#0) * Trying 128.83.21.174... connected * Connected to utw10373.utweb.utexas.edu (128.83.21.174) port 80 (#0) > HEAD / HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.18 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: utw10373.utweb.utexas.edu > Accept: */* > < HTTP/1.1 200 OK HTTP/1.1 200 OK < Server: nginx Server: nginx < Date: Wed, 27 Apr 2016 17:45:56 GMT Date: Wed, 27 Apr 2016 17:45:56 GMT < Content-Type: text/html; charset=UTF-8 Content-Type: text/html; charset=UTF-8 < Content-Length: 19 Content-Length: 19 < Set-Cookie: cache_id=36e1dd7a55420bbdaed5922d061460e7; expires=Wed, 27-Apr-16 18:45:56 GMT; path=/ Set-Cookie: cache_id=36e1dd7a55420bbdaed5922d061460e7; expires=Wed, 27-Apr-16 18:45:56 GMT; path=/ < Last-Modified: Wed, 27 Apr 2016 16:58:09 GMT Last-Modified: Wed, 27 Apr 2016 16:58:09 GMT < ETag: "abdfdae70c71675e-13-5317a507b7971" ETag: "abdfdae70c71675e-13-5317a507b7971" < X-BackendServer: 172.17.99.35:80 X-BackendServer: 172.17.99.35:80 < X-CacheServer: 172.17.99.43 X-CacheServer: 172.17.99.43 < X-Cache: MISS X-Cache: MISS < Accept-Ranges: bytes Accept-Ranges: bytes < Set-Cookie: balancer_id=utweb-px-z1-p02_http|VyD61|VyD61; path=/ Set-Cookie: balancer_id=utweb-px-z1-p02_http|VyD61|VyD61; path=/ < Cache-control: private Cache-control: private < * Connection #0 to host utw10373.utweb.utexas.edu left intact * Closing connection #0
Pay attention to the bottom of the output where you will see something like this to confirm the cache was flushed on that proxy cache server:
No Format < X-Cache: MISS X-Cache: MISS
Check your site for updated content!
...