• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can I cache a CFHTTP process within an include?

Community Beginner ,
Apr 30, 2007 Apr 30, 2007

Copy link to clipboard

Copied

Hi,

Can someone please help me with caching advice?

I want to access a snippet of code (from my own server) to include on my CF scripts. Specifically, it is my website header which contains some SSIs (#include). (My site is mostly static with a couple of CF scripts only.)

Sample header code:
quote:

<div id="access">Skip links here</div>

<div id="header">
<div id="logo">logo here</div>
<div id="tools">e.g. help, sitemap, contact us</div>
<div id="banner">pretty graphic here</div>
<!--#include virtual="/sitenav.shtml"-->
</div>


I thought to workaround this by creating a CF include that used CFHTTP to get the fully parsed header then include it into the CF pages. This works but seems inefficient to do a CFHTTP call each time a CF page loads, so I'd like to cache the process. I was going to put the CFCACHE tag in my CF include file, but am not sure this will work as expected as won't this try to cache the whole CF page, rather than just the CFHTTP process within the include? (which is what I want)

Am I approaching this all wrong? Can anyone help?

Thanks in advanced for your help.
TOPICS
Advanced techniques

Views

430

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Aug 13, 2007 Aug 13, 2007
This is what we ended up doing - prolly not the best solution and still not cached:

Votes

Translate

Translate
Advocate ,
Apr 30, 2007 Apr 30, 2007

Copy link to clipboard

Copied

Can you explain a little more about the reason you're not just using <cfinclude>?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 30, 2007 Apr 30, 2007

Copy link to clipboard

Copied

The contents of my header include code is in my previous post above.

If I use <cfinclude> to include those contents, then ColdFusion will not parse the line that says <!--#include virtual="/sitenav.shtml"--> It will just appear as a comment in the CF pages.

I could do the following:
quote:

<div id="access">Skip links here</div>
<div id="header">
<div id="logo">logo here</div>
<div id="tools">e.g. help, sitemap, contact us</div>
<div id="banner">pretty graphic here</div>
<!--#include virtual="/sitenav.shtml"-->
<cfinclude template"/sitenav.shtml">
</div>


This would allow the static pages to us the #include then the CF pages use <cfinclude> but then this will make the code on my static pages invalid (am using XHTML strict)

Actually, I have previously used a .CFM include for my header and then used #exec cgi on the static pages to include the code BUT I am on a shared hosting server, and now and then the CF server falls over and I get big JRUN or 500 errors at the top of each static page (looks really unprofessional) so that is why I just use static pages/includes for most of the site content.

So, any advice for me? (besides, get a more reliable host {:-)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 30, 2007 Apr 30, 2007

Copy link to clipboard

Copied

A friend actually suggested creating a custom tag that takes a static include as input and looks for all the #include lines and replaces them with <cfincludes>

Sounds like it could work... overkill? 🙂 I probably could use it in other places...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 13, 2007 Aug 13, 2007

Copy link to clipboard

Copied

LATEST
This is what we ended up doing - prolly not the best solution and still not cached:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation