For some reason I use the module trailing slash on few websites to enforce a slash at the end of the URL. I figured today that boost did not cache those pages.

I wonder if there is a trick to let boost cache pages with ending slash?

Comments

drupalove’s picture

Update: Just noticed there is a similar issue at http://drupal.org/node/403814 which did not offer a solution to my case.

bnayal’s picture

I had a similar bug,
When the page alias path is for example: "about/company.html"
and a user tries entering the url with a trailing slash, for example: "about/company.html/" drupal does loading the correct page but boost does not caching it.
I noticed that the bug is in boost.module, in function "boost_transform_url" boost tries loading from drupal_get_normal_path the real node url and with trailing slash it cannot do that.
A workaround which I did and works for me (from first looking) is replacing:

$parts['normal_path'] = drupal_get_normal_path($parts['path']);

With:

$parts['normal_path'] = drupal_get_normal_path($parts['path']);
      if(($parts['normal_path'] == $parts['path']) and (substr($parts['path'], -1) == '/')){
          $parts['normal_path'] = drupal_get_normal_path(substr($parts['path'], 0, -1));
      }

it checks if it didn't find the real path and if so tries again without the trailing slash. but it costs in another db query.

Any thoughts?

Bnaya

alan delval’s picture

Issue summary: View changes

Works without problem #2, using Trailing Slash.

Configuration used (Nginx): https://github.com/perusio/drupal-with-nginx/blob/D7/apps/drupal/drupal_boost.conf

I think until now is the only thing that works.

Anonymous’s picture

I am struggling to understand why

For some reason I use the module trailing slash on few websites to enforce a slash at the end of the URL

is a boost problem. The standard drupal rewrite rules go, if it's not a file or a folder then redirect to index.php which would be cached, so why the installation of an additional module to enforce a trailing slash on an incorrect URI like index.html/ which should result in a 404 should be boost's issue is beyond me. Surely the trailing slash module if it has modified the URI should therefore then change the values and not boost ? Surely boost is working correctly because it is not caching a URI that should result in a 404, it makes little sense to me to modify boost for a limited case to fix broken behaviour by another module, or by a user putting in an incorrect URI.

drupalove’s picture

Status: Active » Closed (works as designed)

I certainly agree with what are you're saying. This issue is old; the search engines and people's understanding of URLs have changed. The standard drupal's URL alias probably meets the needs of everyone. The few cases not covered, if any, can use bnayal's suggestion in comment #2.

I think this issue should be closed since the boost module is not responsible for extending the trailing slash module to meet special cases, would you mind if I close it.

yultyyev’s picture

I get this issue but only on taxonomy pages that very strange. So I tried to solve this by hacking boost module.

boost.module, line 436

    $url = $base_root . request_uri();

Function request_uri() return $uri = '/' . ltrim($uri, '/'); - allowing trailing slash, so I think it would be fine if in the boost module to clean up trailing slashes:

$uri = $base_root . rtrim(request_uri(),'/');
ymeiner’s picture

It seams that the problem here is not exactly request_uri() in boost_transform_url but the lack of hook to control the url structure if needed. I can think of more reasons why the url var should be flexible.

what is the procedure to re-open the issue so we can add a hook to control $url? something like $url = module_invoke_all($hook); before the check if URL is empty.

BTW, if someone chose to go with #6 just fyi that you will also need to change htaccess to fit.

Example:

 RewriteCond %{REQUEST_URI} ^(.*)/$
 RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{SERVER_NAME}%1_%{QUERY_STRING}\.html -s