[Tinhte] Image Attachment Optimization & CDN Support

[Tinhte] Image Attachment Optimization 2.3.0 20170315

No permission to download
Im talking about caching on the CDN (see my posts on the previous page). The files are being served via the CDN, but the CDN does not appear to be caching the images so the CDN is grabbing a fresh copy every time which defeats the purpose.
 
I should mention, i'm serving all of the other static images on my site through the CDN and have a 98% cache status (so 98% of files requested are being served from the CDN cache) - the caching for the files is being set through .htaccess

Code:
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
 
<filesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</filesMatch>
 
<filesMatch "\.(gif|jpg|jpeg|png|swf)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</filesMatch>
 
<filesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A604800
Header append Cache-Control "proxy-revalidate"
</filesMatch>
 
<filesMatch "\.(php|cgi|pl|htm)$">
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</filesMatch>

Could this be conflicting with the cache control being set in /library/Tinhte/AttachImageOptimization/ViewPublic/Attachment/View.php and /library/Tinhte/AttachImageOptimization/ViewPublic/Attachment/View304.php ??
 
Good pickup. max-age is the preferred method over expires, even better to use both.

Add
PHP:
$this->_response->setHeader('Cache-Control', 'max-age=2592000', true);
to both
library/Tinhte/AttachImageOptimization/ViewPublic/Attachment/View.php
and
library/Tinhte/AttachImageOptimization/ViewPublic/Attachment/View304.php

Just looking into this - from what i'm reading you should only use one Cache-Control statement.

So to add the max-age in, you should be replacing

PHP:
$this->_response->setHeader('Cache-Control', 'public', true);

with this

PHP:
$this->_response->setHeader('Cache-Control', 'public, max-age=2592000', true);

And any further cache-control statements should be added in that, seperated with commas.
 
Finally tracked it down, for some reason the images are grabbing the cache control settings from the htaccess for php files

Code:
<filesMatch "\.(php|cgi|pl|htm)$">
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</filesMatch>

Removed the php from the filematch above from the htaccess and it is now giving the correct response headers. It is now caching on the CDN.

Why would the CDN be looking at the PHP cache controls in the htaccess and not the image controls ? I've confirmed it by removing just the PHP part from the filesmatch and it's working fine.

Is it something to do with View.php and View304.php being used to display the attachments ?
 
Just installed this and have a couple of questions.

1) When replying to a comment withsh the attach bb code should you get a thumbnail or a link to the image?

2) When using the below BB code should the image open in lightbox with a thumnail?

View attachment 12114

Cheers!
 
I could get the full images to successfully load from CDN. But on Xenporta the image thumbnails are still being served from my own server. Is there any way to optimise that?
 
I asked my host about APC caching today and this is what they got back to me with:

"Your scripts may support a filesystem based cache which you could enable, however anything alone the lines of APC caching would require a VPS server."

I'm on shared hosting now. Is there any way to get the caching benefit of the add-on without APC? I'm been hunting EVERYWHERE to find an add-on that keeps pictures from re-loading in quotes.
 
I asked my host about APC caching today and this is what they got back to me with:

"Your scripts may support a filesystem based cache which you could enable, however anything alone the lines of APC caching would require a VPS server."

I'm on shared hosting now. Is there any way to get the caching benefit of the add-on without APC? I'm been hunting EVERYWHERE to find an add-on that keeps pictures from re-loading in quotes.

Whelp, I decided to try it and see if it would work without the ACP being installed. It doesn't. I haz a sad.
 
Whelp, I decided to try it and see if it would work without the ACP being installed. It doesn't. I haz a sad.

Check that, seems it might be working after all. But does it only work for images users have uploaded from their computers and not the IMG bbcode tag?

Also, how about when opening the link inside the quote - any other options there than opening the image in the browser separate of the thread?
 
Check that, seems it might be working after all. But does it only work for images users have uploaded from their computers and not the IMG bbcode tag?

Also, how about when opening the link inside the quote - any other options there than opening the image in the browser separate of the thread?

Anyone still around?
 
The queries that were saved is in the /attachments requests, not in the /threads requests...

Still added time and memory in the /thread request so....

If you can show me saving..... That can be easily verified.

The CDN part of this still doesn't work either, because you still have the path wrong.
 
Still added time and memory in the /thread request so....

If you can show me saving..... That can be easily verified.

The CDN part of this still doesn't work either, because you still have the path wrong.

You could not see how it is saving you by looking at the queries because /attachments stats not be shown in there. On another hand, it could help you to show attached images to unregistered members or show in quote...
 
I asked my host about APC caching today and this is what they got back to me with:

"Your scripts may support a filesystem based cache which you could enable, however anything alone the lines of APC caching would require a VPS server."

I'm on shared hosting now. Is there any way to get the caching benefit of the add-on without APC? I'm been hunting EVERYWHERE to find an add-on that keeps pictures from re-loading in quotes.

You could looking at XF caching configuration. You could choose File Cache or APC. There is an option to enable images in quote in this addon.
 
You could not see how it is saving you by looking at the queries because /attachments stats not be shown in there. On another hand, it could help you to show attached images to unregistered members or show in quote...
Doesn't matter. Like others, I uninstalled this.

If its adding to the /thread its doing more harm than good in the long run. Those totals were about the same even with threads without attachments.

CDN option never worked either.
 
Hi,

Does this add on need to be updated for 1.2? I remember there being a template modification in the TMS add on associated with it.

Can anyone confirm this is working on 1.2?
 
Top Bottom