Force cache a php page

Shibashish shib4u at gmail.com
Tue Feb 22 13:15:15 CET 2011


On Tue, Feb 22, 2011 at 5:31 PM, Traian Bratucu <
traian.bratucu at eea.europa.eu> wrote:

> Just a note: please be aware that by default PHP will issue some headers
> that will not permit caching (Cache-Control). Please also verify php.ini.
>
> Regarding your regex... you wrote “phg”...
>
>
>
> Traian
>
>
>
> *From:* varnish-misc-bounces at varnish-cache.org [mailto:
> varnish-misc-bounces at varnish-cache.org] *On Behalf Of *Shibashish
> *Sent:* Tuesday, February 22, 2011 12:57 PM
> *To:* varnish-misc at varnish-cache.org
> *Subject:* Force cache a php page
>
>
>
> Hi All,
>
>
>
> I have a website under varnish-2.1.5-1. I have a php page (test.php) which
> is kinda static and I can cache it for some time (5 mins). The URLs hitting
> this page are like the following due to which the varnish cache is MISSed
> and the apache webserver is being hit. How do I do a regex to overcome this?
> My trial config is mentioned in the end....
>
>
>
>      1.00 TxURL
>  /test.php?id=219488&TabID=3&Res=2&dt=866845858823555200
>
>      1.00 TxURL
>  /test.php?id=253114&TabID=3&Res=2&dt=846642321042837100
>
>      1.00 TxURL
>  /test.php?id=104326&TabID=3&Res=2&dt=575570316149238400
>
>      1.00 TxURL
>  /test.php?id=30946&TabID=3&Res=2&dt=109061349055833870
>
>      1.00 TxURL
>  /test.php?id=109331&TabID=3&Res=2&dt=284968385895093150
>
>      1.00 TxURL
>  /test.php?id=147630&TabID=3&Res=2&dt=182582005324904030
>
>      1.00 TxURL
>  /test.php?id=226618&TabID=3&Res=2&dt=567666382104328500
>
>      1.00 TxURL
>  /test.php?id=44438&TabID=3&Res=2&dt=894643067109792400
>
>      1.00 TxURL
>  /test.php?id=219029&TabID=3&Res=2&dt=120583019713746690
>
>      1.00 TxURL
>  /test.php?id=92700&TabID=3&Res=2&dt=812672457300415500
>
>      1.00 TxURL
>  /test.php?id=244364&TabID=3&Res=2&dt=543154670573941800
>
>      1.00 TxURL
>  /test.php?id=204543&TabID=3&Res=2&dt=108553982023531000
>
>      1.00 TxURL
>  /test.php?id=155579&TabID=3&Res=2&dt=609157805933082500
>
>      1.00 TxURL
>  /test.php?id=100248&TabID=3&Res=2&dt=329215175928002100
>
>      1.00 TxURL
>  /test.php?id=155347&TabID=3&Res=2&dt=324280933690657500
>
>      1.00 TxURL
>  /test.php?id=153167&TabID=3&Res=2&dt=262366359106033180
>
>      1.00 TxURL
>  /test.php?id=175035&TabID=3&Res=2&dt=748310387497392400
>
>      1.00 TxURL
>  /test.php?id=122942&TabID=3&Res=2&dt=89373125154077630
>
>      1.00 TxURL
>  /test.php?id=157531&TabID=3&Res=2&dt=164945409132294180
>
>      1.00 TxURL
>  /test.php?id=100248&TabID=3&Res=2&dt=381019014643790400
>
>      1.00 TxURL
>  /test.php?id=103053&TabID=3&Res=2&dt=597790616600820500
>
>
>
>
>
> vcl_recv
>
>
>
>  if (req.url ~ "\.phg(\?.*)?$") {
>
>   return(lookup);}
>
>
>
> Thanks.
>
>
>
> --
>
> Shib
>

Thanks for your reply. The header has....

Cache-Control max-age=600, public

The regex has been corrected. Just to let you know that any subsequent
requests to the same url, i.e. /test.php?abc, if hit for a second or 3rd
time or more, shows a cache HIT.

ShiB.
while ( ! ( succeed = try() ) );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110222/916ca30b/attachment-0003.html>


More information about the varnish-misc mailing list