0

I am using Stash static caching (and it is AWESOME). I'm using Stash 2.4.5 and EE 2.7.2. I am also using Low Search 3.0.4.

So I have the {exp:stash:static} tag on my homepage, which is great. But if it's there (or, I should say, if my static_cache folder has a cached file for my homepage), my Low Search form doesn't work. When I submit a keyword search, it just loads the homepage.

The search works fine when I am logged in, presumably because I have Stash disabled for logged in users.

So, based on my .htaccess, I'd expect it to NOT load the homepage from the cache file because it's a POST.

Any idea what I'm doing wrong, or how to get this to work? I'd really like to keep my homepage static caching working.

In my .htaccess, I have

#################################################################################
# START MUSTASH STATIC CACHE RULES

# -------------------------------------------------------------------------------
# default_site
# -------------------------------------------------------------------------------

# Exclude image files
RewriteCond $1 !\.(gif|jpe?g|png|ico)$ [NC]

# We only want GET requests
RewriteCond %{REQUEST_METHOD} GET

# Exclude CSS/ACT EE URLs and 'preview'
RewriteCond %{QUERY_STRING} !^(css|ACT|URL|preview)

# Uncomment this if you want to disable static caching for logged-in users
RewriteCond %{HTTP_COOKIE} !exp_sessionid [NC]

# Remove index.php from conditions
RewriteCond $1 ^(index.php/)*(.*)(/*)$

# Check if cached index.html exists
RewriteCond /path/to/my/public_html/static_cache/1/$2/index.html (.*\.(.*))$
RewriteCond %1 -f

# Rewrite to the cached page
RewriteRule ^(index.php/*)*(.*)(/*) /static_cache/1/$2/index.%2 [L]

# END MUSTASH STATIC CACHE RULES
#################################################################################
3

I finally got this working (Low Search working with Stash static cached homepage)!!!

I added the following rule to my .htaccess, to get it to really really ignore POST requests. I'm not sure why this works (maybe it's my server environment? I'm on a Nexcess EE-Optimized plan).

So I added the following RewriteCond

RewriteCond %{THE_REQUEST} ^(GET)

And now, my Low Search form works and I can keep my homepage static-cached!

1

Your htaccess looks OK to me--I think it should be doing what you want. But you could try changing the Request Method match from this:

RewriteCond %{REQUEST_METHOD} GET

to this more strict match:

RewriteCond %{REQUEST_METHOD} ^GET$

Another rewrite technique I've used, that I know works, is to enclose the rules in a Limit block, like:

<Limit GET>
   # your caching rewrite rules here
</Limit>
  • Hi Jay. Thanks for your suggestion. I've tried both of those things, and neither did the trick :( BUT, I did finally get it working! See my answer below. – Gary Reckard Jan 21 '14 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.