Solved

Apache: Cache based of query

Posted on 2013-06-23
3
186 Views
Last Modified: 2013-07-08
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
Comment
Question by:hankknight
  • 2
3 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39270383
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
 
LVL 16

Author Comment

by:hankknight
ID: 39270941
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
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39272227
I can't find any Apache directive that will take action based on the contents of a query string.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now