anchor.diff:  	    ets:insert(Db, {TagTm, TimeZero}),
   	    {reply,ok,State};
   	true ->
  +            %% Set file name and monitor, read content
   	    File = filename:flatten(Fname),
   	    ets:insert(Db, {res_optname(Option), File}),
  -	    Bin =
  -		case erl_prim_loader:read_file_info(File) of
  -		    {ok, Finfo0} ->
  -			Finfo = Finfo0#file_info{access = undefined,
  -						 atime = undefined},
  -			ets:insert(Db, {TagInfo, Finfo}),
  -			ets:insert(Db, {TagTm, times()}),
  -			case erl_prim_loader:get_file(File) of
  -			    {ok, B, _} -> B;
  -			    _ -> <<>>
  -			end;
  -		    _ ->
  -                        ets:insert(Db, {TagInfo, undefined}),
  -                        TimeZero = - (?RES_FILE_UPDATE_TM + 1), % Early enough
  -                        ets:insert(Db, {TagTm, TimeZero}),
  -                        <<>>
  -		end,
  -	    handle_set_file(ParseFun, Bin, From, State);
  +            handle_update_file(
  +              undefined, File, TagTm, TagInfo, ParseFun, From, State);
   	false -> {reply,error,State}
       end.
   
  -handle_set_file(ParseFun, Bin, From, State) ->
  -    case ParseFun(Bin) of
  +handle_set_file(ParseFun, File, Bin, From, State) ->
  +    case ParseFun(File, Bin) of
   	error ->
   	    {reply,error,State};
   	Opts ->
   	    handle_rc_list(Opts, From, State)
  +    end.
  +
  +handle_update_file(
  +  Finfo, File, TagTm, TagInfo, ParseFun, From, #state{db = Db} = State) ->
  +    %%
  +    %% Update file content if file has been updated
  +    %%
  +    case erl_prim_loader:read_file_info(File) of
  +        {ok, Finfo} ->
  +            %% No file update - we are done
  +            {reply, ok, State};
  +        {ok, Finfo_1} ->
  +            %% File updated - read content
  +            ets:insert(Db, {TagInfo, Finfo_1}),
  +            ets:insert(Db, {TagTm, times()}),
  +            Bin =
  +                case erl_prim_loader:get_file(File) of
  +                    {ok, B, _} -> B;
  +                    _ -> <<>>
  +                end,
  +            handle_set_file(ParseFun, File, Bin, From, State);
  +        _ ->
  +            %% No file - clear content and reset monitor
  +            ets:insert(Db, {TagInfo, undefined}),
  +            ets:insert(Db, {TagTm, times()}),
  +            handle_set_file(ParseFun, File, <<>>, From, State)
       end.
   
   %% Byname has lowercased names while Byaddr keep the name casing.
  
positive.code: 	      Option, Fname, res_resolv_conf_tm, res_resolv_conf_info,
  	      undefined, From, State);
  
  	{res_set, hosts_file=Option, Fname} ->
  	    handle_set_file(
  	      Option, Fname, res_hosts_file_tm, res_hosts_file_info,
  	      fun (Bin) ->
  		      case inet_parse:hosts(
  			     Fname, {chars,Bin}) of
  			  {ok,Opts} ->
  			      [{load_hosts_file,Opts}];
  			  _ -> error
  
negative.code: gethostname()         -> db_get(hostname).
  
  res_update_conf() ->
      res_update(resolv_conf, res_resolv_conf_tm).
  
  res_update_hosts() ->
      res_update(hosts_file, res_hosts_file_tm).
  
  res_update(Option, TagTm) ->
      case db_get(TagTm) of
  	undefined -> ok;
  	Tm ->
  	    case times() of
  		Now when Now >= Tm + ?RES_FILE_UPDATE_TM ->
                      %% Enough time has passed - request server to update
                      res_option(Option, Tm);
  		_ -> ok
  	    end
      end.
  