Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Apache: Cache based of query

Posted on 2013-06-23
3
Medium Priority
?
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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 this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

670 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