Solved

Apache: Cache based of query

Posted on 2013-06-23
3
190 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 83

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 83

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 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