Even in the latest Joomla 1.5 Last-Modified Header is non-customizable and returns current date, which is imho against seo-basics. Does any one know how (or component) to make Joomla 1.5 return Last-Modified header based on last modified article?
JResponse::setHeader( 'Last-Modified', $yourDateHere ); should work. However, if you want to add this without hacking com_content, you'll need to build a plugin that will detect when com_content is being called, then retrieve the article from the database to get the modified date on the article.
#All
Feel free to download and test lite version of plugin "Last-Modified Any Content Lite". This one allows you to send right header information about last-modified date of page for search bots to increase indexing your websites.
Related
Use case: A user can bookmark a link which contains a pdf-document for downloading or viewing it online.
The url contains a version number provided by liferay.
Is it possible to ensure that you always get the latest version of the bookmarked pdf-document even if the url was bookmarked months ago ?
The uploaded pdf-documents are versioned by Liferays document library.
Of course you can remove the version number from the pdf-link but this i guess would lead to the problem that your browser will cache the document and you are again not sure if your pdf- document is the latest one.
Does anyone can drop me a hint ?
No, you cannot do it, so the only solution is to make a hook for the method that fetches the document. In this case I think you should override some of the DLFileEntryLocalServiceUtil methods. With these two links you will have enough information:
Override a service - https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/overriding-a-portal-service-using-a-hook
DLFileEntryLocalServiceUtil - https://docs.liferay.com/portal/6.2/javadocs/com/liferay/portlet/documentlibrary/service/DLFileEntryLocalServiceUtil.html
Good luck!
I'm quite new to WSO2. Although I managed to find a quick hack to ignore the version number from the url path when calling my services, I would like to know if there's an efficient way of doing this: /Personal/1.0.0/Members?tenantId=1&entityNumber=1
Make that API with default version in the Implementation Tab by checking "Make this default version" checkbox. Check here for more and the below image for how to do it.
Once you have checked that "Make this default version" option, You can two URLs for the API in the Store like below
A default API can be invoked without specifying the version number in
the URL. For example, if you mark http://host:port/youtube/2.0 as the
default version when the API has 1.0 and 3.0 versions as well,
requests made to http://host:port/youtube/ get automatically routed to
version 2.0.
If you mark any version of an API as the default, you get two API URLs
in its Overview page in the API Store. One URL is with the version and
the other is without. You can invoke a default version using both
URLs.
From APIM 1.9.0 onwards there is a new feature introduced as "version strategy" where you can provide {version} tag in the context in any place. As an example, if you provide the context as api/{version}/test and in the version field as 1.0.0v it will replace the URL pattern as api/1.0.0/test.
Same like that if you really need to get rid of version number apart from the above answer you can provide a text in the version field since it allows text as well.
E.g.,
In context -> api/{version}/test and in version -> text will make the url pattern as api/text/test
But please note this is not recommended since version is supposed to use version number. You can use the default url as explained in Abiraman's answer. But since version field number allows numeric and text for a situation like -> 1.0.0v, 1v, 1.0.b you can try this as well.
On my website I have some google map overlay images that get updated once per year. So they are candidates for browser caching.
What is the best way of specifying the caching? E.g. if I use ...
Header set Cache-Control "max-age=31536000, public"
(31536000 secs = 1 year)
as far as I understand it this is no use, as if somebody accesses the website one day before I update the images, then they will have to wait one year before they see the correct new images? Can I specify a date when the images will expire rather than a duration. Or is there a better way to handle this?
Also, I cant seem to get the regular expression to work. Can anyone see what could be wrong with this code in my .htaccess file (I want to match all .PNG images in a specific directory) ...
<FilesMatch "\/overlayDirectoty\/[^\.]+\.png$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
I'm on shared Linux/Apache hosting (goDaddy).
UPDATE
The image files have an average size of 580 bytes. But many will be downloaded as the user pans and zooms the map (there are 12000 of them in total).
UPDATE
I've just discovered this. If I know I am going to update the images on 1st Jan every year at earliest, will this work? ...
Header set Expires "Sun, 1 Jan 2014 00:00:00 GMT"
In this case I would set the image to never expire but then when you do change it, use a different file-name.
I'm not sure you need to do anything at all.
Is Apache already responding with a Last-modified header? (It should be, for static png files.) If so, then browsers should be sending an If-modified-since header with all subsequent requests; this will cause your server to reply with an HTTP 304 instead of actually re-sending the image. (The ETag header acts similarly.)
When you do update your files--that one time per year--the file update time will change and all subsequent requests will get the new version of the png file.
The down side of this approach is that every browser will still make a request to your server for each image it's trying to render--so you'll see many 304s in your logs. But that 304 traffic is (generally) quite minimal when compared with multi-kilobyte image files.
First you have to consider whether you want to take advantage of revalidating using etags.
http://en.wikipedia.org/wiki/HTTP_ETag
You can either let the browser cache the image entirely, or let the client perform a head request that is only used to validate whether the etag is still the same. The e tag is caculated by apache on the fly using file modification time, name and size.
In other words: If your image changes, its e-tag changes.
If the e-tag does not change, the client uses the cacehd version and does not download the file.
However you will have the overhead of a head request, which is minimal and I would recommend this approach.
Nevertheless for completeness lets discuss the other possibilities:
Change the filename
When the filename changes, the browser will re-fetch it. A common practice is to append a so called "cachebreaker" to the file as a query string. If you generate your src urls in php, just append something like the modification timestamp so the url looks like
image.jpg?UNIX_TIMESTAMP
use a caching rule that expires at your point of choosing
I think this is not good to maintain because you nail yourself down as the when refresh the image and you cannot before. But then changing the filename always remains as a measure of "last resort".
You could set the header dynamically using a scripting language and calculate it, however this will be not as performant as delivering using the webserver. There are also combinations like mod_xsendfile, but that would be absolutely overkill for your demand.
No, I think you are not looking at the bigger picture.
mod_expires lets you pecify caching lifetimes in reference to the current time (access) or te file modification. If you make sure your file modification time is correct, just set it inreference to that.
Read up here:
http://httpd.apache.org/docs/2.4/mod/mod_expires.html
But what you could really do is, just code it!
Its only a header you know, and no one forces you to use mod expires.
Just set the header manually using mod_headers!
Read up here:
http://httpd.apache.org/docs/2.4/mod/mod_headers.html
I will not cover this with examples because i really think you should use etag.
I am learning about apache and its various modules, currently i am confused about mod_expires. What i read so far is that using this module we can set future expiry header for static files so that browser need not to request them each time.
I am confused about the fact that if some one change css/js or any image file in between, how will browser come to know about it since we have already told the browser that this is not going to change say for next 1 year.
Thanks in advance
It may not be possible for all provided content on your HTTP server, but you can simply change the name of the file to update a file on the client side from the server. At that point, the browser will download the new content.
Sometimes, for websites with less traffic it is far more functional to set the cache to a much lower value.
An expiration of 365 days should always be used with caution, and the fact that you can set an expiration of 1 year does not mean you always have to do it. In other words, do not fall prey to premature optimization.
A good example of setting cache expiration to 1 year are countries' flags, which are not likely to change. Also, be aware that with a simple browser refresh of a page, the client can discard the local cache and download the content again from the origin.
A good and easy way of testing all this is to use Firefox with Firebug. With this extension, you can analyze requests and responses.
Here you can find the RFC specifications.
We want to set expires headers for used images, css and javascript to improve pagespeed, but we are aware of the cachingproblem when modifying a css or js script.
Is it possible to add a meta or other tag in the file which loads the xhtml which tells the browser to refresh every element, no matter what caching is set on existing images, css or js?
As far as I know, there's no such shortcut.
And even if it was - what would be the point? Sending such a header would defeat the purpose of the future expiration header in the first place.
When setting expiration headers, you need to add some sort of asset versioning to to your elements, such as <link rel="stylesheet" href="css/style.css?v=2">
Changing the path to the asset would achieve the same goal.
Yes this is a hassle. But cache invalidation is a hard problem, there's really no easy way around it.
What you probably want to do is version your static content. so say you have a main.css file then you can version this by renaming it to main_0.css (just an example) and then you would set the cache expire to a year. if you ever need to update main.css just increment the version number and update your references. Then all clients will get the latest version.
There are several solutions that can do this versioning for you, but this is the basic principle..
I have always found theese resources very usefull when having cache related questions:
http://code.google.com/intl/no/speed/page-speed/docs/caching.html
http://code.google.com/intl/no/speed/page-speed/docs/filters.html
Hope this helps.
EDIT
Here is a versioning solution (mod_pagespeed) that does what i explained above:
http://code.google.com/intl/no/speed/page-speed/docs/filter-cache-extend.html
Is it possible to add a meta or other tag in the file which loads the xhtml which tells the browser to refresh every element, no matter what caching is set on existing images, css or js?
Not as far as I'm aware.
We want to set expires headers for used images, css and javascript to improve pagespeed
This is a good thing in my opinion.
but we are aware of the cachingproblem when modifying a css or js script.
If you're making drastic changes to CSS or JS then you ought to be staging the changes anyway. Manage these changes by having the new CSS and JS on a different path and change the references in your HTML when making the change. This allows you to:
instantly roll out / back
make selective rollouts by dynamically generating those references
web logs now provide clear audit trail for following up bug reports
avoid any issues with short term caching of CSS and JS