Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a site that involves user logins for certain content. I am leveraging browser caching in the .htaccess file. When a user logs in, they are redirected to a profile page. The problem I'm having is that when the user navigates back to the homepage, they are getting a cached version, which behaves as if they are not logged in. If they refresh the home page, they see the proper content, but I need to figure out how to make sure they get the proper content in the first place.

Here is the code I put in my .htacces:

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
share|improve this question

closed as off-topic by Rarst Jan 2 at 22:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions should be specific to WordPress within defined scope (merely happening in its context, such as generic PHP/JS/HTML/CSS, is insufficient). Might be better asked at Stack Overflow or other appropriate site of Stack Exchange network." – Rarst
If this question can be reworded to fit the rules in the help center, please edit the question.

Can you verify that if you remove the last section, the issue goes away? Also, can you use Chrome Developer Tools (or equivalent) to see header information for each page load? –  Khan Jan 2 at 16:53
Yes, I just checked, and if I remove the 2nd part, the problem goes away. Is getting rid of browser caching my only option? When the second part is included, the Headers on the home page shows 200 OK (from cache) –  user1380281 Jan 2 at 17:33
Well if you set default expiration to two days and that includes HTML you are serving - duh! :) Not really WP issue, if you need help ironing out caching in general Stack Overflow is probably better fit. –  Rarst Jan 2 at 22:39
You were right, I removed ExpiresDefault "access 2 days" and it seems to have resolved the problem. –  user1380281 Jan 2 at 23:07