logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Quasi dynamic regeneration?
Author
iaw4



Joined: 25 Mar 2014
Posts: 2
Location: Los Angeles

PostPosted: Sun 24 Apr '16 17:31    Post subject: Quasi dynamic regeneration? Reply with quote

I can do what I want in php, but there may be a better faster Apache solution:

Code:

  <directory /var/www/html>
       $basename = base of any html  $url file request;
       If (age $url file request < age $basename.tpl)
              run perl retemplate.pl $basename.tpl
       Now serve $url file request
   <directory>


Is there a common way to do this? Advice appreciated.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Sun 24 Apr '16 17:34    Post subject: Reply with quote

I suggest using mod rewrite. There are some example over forum.

If you still have a question please ask again.
Back to top
iaw4



Joined: 25 Mar 2014
Posts: 2
Location: Los Angeles

PostPosted: Sun 24 Apr '16 18:05    Post subject: Reply with quote

thank you, james.

I looked through the 10 pages that come up when I search the site for mod-rewrite. closest I saw is the "file exists" condition in your answer in https://www.apachelounge.com/viewtopic.php?p=17632 .

I could see neither an example of the basename extraction, nor an example of how to trigger not rewriting to another filename, but pausing to run the retemplation script on the filename, and then trying the original a second time.

it would seem like a fairly standard task. if this is complex, I could always fall back to php, of course...
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Sun 24 Apr '16 18:38    Post subject: Reply with quote

I would use a scripting language, too and rewrite only the html to that script, since I don't know of the check the age of a file with apache.

Code:

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*\.htm)$ index.php/$1


I wonder why you want to use php since template engine seems to run on perl.

If the regex above is not what you want you can use https://regexper.com/#^%28.*\.htm%29%24 to find the best one for your needs.

To check the file age it might work with

Code:
<If "%{LAST_MODIFIED}
https://httpd.apache.org/docs/2.4/de/expr.html But I never tried that before.
Back to top


Reply to topic   Topic: Quasi dynamic regeneration? View previous topic :: View next topic
Post new topic   Forum Index -> Apache