Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

mod_rewrite And Browser Caching

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


drew at mykitchentable

Aug 18, 2012, 7:55 AM

Post #1 of 4 (472 views)
Permalink
mod_rewrite And Browser Caching

I've been working at this for days and couldn't figure out why a
mod_rewrite rule wasn't working. My situation was that I wanted to
redirect this:

http://domain.com/unique_directory/whatever

to

https://domain.com/unique_directory/whatever

While not redirecting http://domain.com/other_directories/whatever

After beating my head for a few days and realizing first attempts were
creating a rewrite loop, I finally came up with this syntax:

RewriteEngine /On/
RewriteCond /%{HTTPS} off/
RewriteCond /%{REQUEST_URI} \/unique_directory\/ [NC]/
RewriteRule /(.*) https://%{HTTP_HOST}%{REQUEST_URI}

/Yet on the PC I had been using for testing, the redirects were still
failing using both Firefox 14 and Internet Explorer 9. I had many tabs
open in Firefox so I never closed and reopened it but I did close and
reopen IE9. Attempts to load pages still timed out just like when I had
the rewrite loop in place.

Also, I had enabled the RewriteLog for debugging with RewriteLogLevel
9. I thought it odd that I would not see requests from my IP address
hitting the rewrite log.

Finally in desperation, I went to another PC and tested with the same
browsers. Redirection worked just as I expected it to and I could see
those in the rewrite log.

So now I'm trying to understand how browsers cache information and what
it takes to get them to forget that information.

Thanks in advance.

Cheers,

Drew

--
Like card tricks?

Visit The Alchemist's Warehouse to
learn card magic secrets for free!

http://alchemistswarehouse.com


sebbaz at gmail

Aug 18, 2012, 8:30 AM

Post #2 of 4 (442 views)
Permalink
Re: mod_rewrite And Browser Caching [In reply to]

On 18 August 2012 15:55, Drew Tomlinson <drew [at] mykitchentable> wrote:
> I've been working at this for days and couldn't figure out why a mod_rewrite
> rule wasn't working. My situation was that I wanted to redirect this:
>
> http://domain.com/unique_directory/whatever
>
> to
>
> https://domain.com/unique_directory/whatever
>
> While not redirecting http://domain.com/other_directories/whatever
>
> After beating my head for a few days and realizing first attempts were
> creating a rewrite loop, I finally came up with this syntax:
>
> RewriteEngine On
> RewriteCond %{HTTPS} off
> RewriteCond %{REQUEST_URI} \/unique_directory\/ [NC]
> RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
>
> Yet on the PC I had been using for testing, the redirects were still failing
> using both Firefox 14 and Internet Explorer 9. I had many tabs open in
> Firefox so I never closed and reopened it but I did close and reopen IE9.
> Attempts to load pages still timed out just like when I had the rewrite loop
> in place.
>
> Also, I had enabled the RewriteLog for debugging with RewriteLogLevel 9. I
> thought it odd that I would not see requests from my IP address hitting the
> rewrite log.
>
> Finally in desperation, I went to another PC and tested with the same
> browsers. Redirection worked just as I expected it to and I could see those
> in the rewrite log.
>

An alternative would be to use a client that does not cache, for
example curl or wget.

> So now I'm trying to understand how browsers cache information and what it
> takes to get them to forget that information.
>
> Thanks in advance.
>
> Cheers,
>
> Drew
>
> --
> Like card tricks?
>
> Visit The Alchemist's Warehouse to
> learn card magic secrets for free!
>
> http://alchemistswarehouse.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


ben at indietorrent

Aug 18, 2012, 8:51 AM

Post #3 of 4 (443 views)
Permalink
Re: mod_rewrite And Browser Caching [In reply to]

On 8/18/2012 11:30 AM, sebb wrote:
> On 18 August 2012 15:55, Drew Tomlinson <drew [at] mykitchentable> wrote:
>> I've been working at this for days and couldn't figure out why a mod_rewrite
>> rule wasn't working. My situation was that I wanted to redirect this:
>>
>> http://domain.com/unique_directory/whatever
>>
>> to
>>
>> https://domain.com/unique_directory/whatever
>>
>> While not redirecting http://domain.com/other_directories/whatever
>>
>> After beating my head for a few days and realizing first attempts were
>> creating a rewrite loop, I finally came up with this syntax:
>>
>> RewriteEngine On
>> RewriteCond %{HTTPS} off
>> RewriteCond %{REQUEST_URI} \/unique_directory\/ [NC]
>> RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
>>
>> Yet on the PC I had been using for testing, the redirects were still failing
>> using both Firefox 14 and Internet Explorer 9. I had many tabs open in
>> Firefox so I never closed and reopened it but I did close and reopen IE9.
>> Attempts to load pages still timed out just like when I had the rewrite loop
>> in place.
>>
>> Also, I had enabled the RewriteLog for debugging with RewriteLogLevel 9. I
>> thought it odd that I would not see requests from my IP address hitting the
>> rewrite log.
>>
>> Finally in desperation, I went to another PC and tested with the same
>> browsers. Redirection worked just as I expected it to and I could see those
>> in the rewrite log.
>>
>
> An alternative would be to use a client that does not cache, for
> example curl or wget.
>
>> So now I'm trying to understand how browsers cache information and what it
>> takes to get them to forget that information.
>>
>> Thanks in advance.
>>
>> Cheers,
>>
>> Drew

Where Firefox is concerned, there's a plug-in that enables one to toggle
the browser cache with a convenient toolbar icon:

http://pau.santesmasses.net/cachetoggle/

This little tool is indispensable to any serious developer.

(I am in no way affiliated with this plug-in; I'm just a satisfied user.)

-Ben


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


james.rapp at sap

Aug 20, 2012, 11:43 AM

Post #4 of 4 (438 views)
Permalink
RE: mod_rewrite And Browser Caching [In reply to]

> On 18 August 2012 15:55, Drew Tomlinson <drew [at] mykitchentable> wrote:
>> So now I'm trying to understand how browsers cache information and what it
>> takes to get them to forget that information.

Make your pages adhere to the RFC spec for caching. Use cache-control headers such as "no-cache" or "private" to ensure cache is revalidated against the source. You haven't provided any details on the type of page you're calling from "whatever" but likely the resource is considered cacheable and the browser doesn't need to revalidate against httpd.

There is a pretty good overview of browser caching here: http://www.mnot.net/cache_docs/

James Rapp


-----Original Message-----
From: Ben Johnson [mailto:ben [at] indietorrent]
Sent: Saturday, August 18, 2012 9:51 AM
To: users [at] httpd
Subject: Re: [users [at] http] mod_rewrite And Browser Caching



On 8/18/2012 11:30 AM, sebb wrote:
> On 18 August 2012 15:55, Drew Tomlinson <drew [at] mykitchentable> wrote:
>> I've been working at this for days and couldn't figure out why a mod_rewrite
>> rule wasn't working. My situation was that I wanted to redirect this:
>>
>> http://domain.com/unique_directory/whatever
>>
>> to
>>
>> https://domain.com/unique_directory/whatever
>>
>> While not redirecting http://domain.com/other_directories/whatever
>>
>> After beating my head for a few days and realizing first attempts were
>> creating a rewrite loop, I finally came up with this syntax:
>>
>> RewriteEngine On
>> RewriteCond %{HTTPS} off
>> RewriteCond %{REQUEST_URI} \/unique_directory\/ [NC]
>> RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
>>
>> Yet on the PC I had been using for testing, the redirects were still failing
>> using both Firefox 14 and Internet Explorer 9. I had many tabs open in
>> Firefox so I never closed and reopened it but I did close and reopen IE9.
>> Attempts to load pages still timed out just like when I had the rewrite loop
>> in place.
>>
>> Also, I had enabled the RewriteLog for debugging with RewriteLogLevel 9. I
>> thought it odd that I would not see requests from my IP address hitting the
>> rewrite log.
>>
>> Finally in desperation, I went to another PC and tested with the same
>> browsers. Redirection worked just as I expected it to and I could see those
>> in the rewrite log.
>>
>
> An alternative would be to use a client that does not cache, for
> example curl or wget.
>
>> So now I'm trying to understand how browsers cache information and what it
>> takes to get them to forget that information.
>>
>> Thanks in advance.
>>
>> Cheers,
>>
>> Drew

Where Firefox is concerned, there's a plug-in that enables one to toggle
the browser cache with a convenient toolbar icon:

http://pau.santesmasses.net/cachetoggle/

This little tool is indispensable to any serious developer.

(I am in no way affiliated with this plug-in; I'm just a satisfied user.)

-Ben


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.