Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Apache: Cache based of query

I want to cache static files based on the request query.

For example:
http://www.example.com/image.jpg?CacheTime=day
http://www.example.com/image.jpg?CacheTime=week
http://www.example.com/image.jpg?CacheTime=year

Is there any way to do something like this?
<QueryMatch CacheTime=day>
 Header unset Pragma
 ExpiresActive Off
 Header unset ETag
 Header unset Last-Modified
 Header set Cache-Control "max-age=86400, public"
</FilesMatch>

<QueryMatch CacheTime=day>
 Header unset Pragma
 ExpiresActive Off
 Header unset ETag
 Header unset Last-Modified
 Header set Cache-Control "max-age=604800, public"
</FilesMatch>

<QueryMatch CacheTime=year>
 Header unset Pragma
 ExpiresActive Off
 Header unset ETag
 Header unset Last-Modified
 Header set Cache-Control "max-age=31536000, public"
</FilesMatch>

Open in new window

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

I think maybe this is what you want:  http://tutorialpedia.org/tutorials/Apache+enable+file+caching+with+htaccess.html  Your code above doesn't identify what is to have it's cache settings altered.
Avatar of hankknight

ASKER

I want this to be cached for one day:
http://www.example.com/image.jpg?CacheTime=day

I want this to be cached for one week:
http://www.example.com/image.jpg?CacheTime=week

I want this to be cached for one year:
http://www.example.com/image.jpg?CacheTime=year

These links all have the same file path, filename and extension.  The only thing that is different is the query.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial