You can add the header "Cache-Control: only-if-cached" to the client request 
using header_rewrite.  The client would receive a 504 by default and you should 
be able to modify this to a 404 using the header_rewrite plugin again.

Here is an example of a non cacheable response:
09:07:36 homer:~$ curl -D -   http://127.0.0.1:8080/200.php
HTTP/1.1 200 OK
Date: Tue, 07 May 2019 16:07:46 GMT
Server: ATS/9.0.0
X-Powered-By: PHP/7.2.17
Content-Length: 5
Content-Type: text/html; charset=UTF-8
Age: 0
Connection: keep-alive

test

09:07:46 homer:~$ curl -D - -H 'Cache-Control: only-if-cached'  
http://127.0.0.1:8080/200.php
HTTP/1.1 504 Not Cached
Date: Tue, 07 May 2019 16:09:55 GMT
Connection: keep-alive
Server: ATS/9.0.0
Cache-Control: no-store
Content-Type: text/html
Content-Language: en
Content-Length: 340

<HTML>
<HEAD>
<TITLE>Not In Cache</TITLE>
</HEAD>

<BODY BGCOLOR="white" FGCOLOR="black">
<H1>Not In Cache</H1>
<HR>

<FONT FACE="Helvetica,Arial"><B>
Description: Your request mandated that the document come from cache, but
the document is not present in cache.  As requested, the transaction
is being terminated.
</B></FONT>
<HR>
</BODY>

Here is an example of a cacheable response:
09:10:17 homer:~$ curl -D - http://127.0.0.1:8080/200_cache.php
HTTP/1.1 200 OK
Date: Tue, 07 May 2019 16:06:48 GMT
Server: ATS/9.0.0
X-Powered-By: PHP/7.2.17
Cache-Control: max-age=300
Last-Modified: Thu, 12 Feb 2009 23:00:00 GMT
Content-Length: 4
Content-Type: text/html; charset=UTF-8
Age: 219
Connection: keep-alive

xxx
09:10:27 homer:~$ curl -D - -H 'Cache-Control: only-if-cached'  
http://127.0.0.1:8080/200_cache.php
HTTP/1.1 200 OK
Date: Tue, 07 May 2019 16:06:48 GMT
Server: ATS/9.0.0
X-Powered-By: PHP/7.2.17
Cache-Control: max-age=300
Last-Modified: Thu, 12 Feb 2009 23:00:00 GMT
Content-Length: 4
Content-Type: text/html; charset=UTF-8
Age: 221
Connection: keep-alive

xxx

-Bryan



> On Apr 23, 2019, at 6:01 AM, Guofeng Zhang <[email protected]> wrote:
> 
> Hi,
> 
> I need to provide a way for our machines on a private network to download 
> software somewhere. This private network has no internet connection. I think 
> this is can be easily accomplished by using TS as a forward proxy server on 
> the private network. 
> 
> I can fill the TS's cache by running a script on another machine that has 
> internet connection to download and cache software by a TS, then copy the 
> TS's cache directory (which is configured by storage.config) to the TS on the 
> private network.
> 
> I need the TS on the private network to return objects if they are hit, or 
> return 404 (Not Found) if they are missed, and the TS should not try to 
> connect to original servers in any case.
> 
> By reading the docs, I cannot know how to configure TS on the private 
> network. I think I can configure it like:
>  url_regex=^https?://(www.)?apache.org/dev/ <http://apache.org/dev/> 
> ttl-in-cache=6h
> and give ttl-in-cache a very large value. Is it the only configuration to do 
> it?
> 
> Your help is appreciated.
> 
> Thanks for your help.
> 
> Guofeng
> 

Reply via email to