Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

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

0
hankknight
Asked:
hankknight
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
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.
0
 
hankknightAuthor Commented:
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.
0
 
Dave BaldwinFixer of ProblemsCommented:
I can't find any Apache directive that will take action based on the contents of a query string.
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now